Yes. First we can build a numpy array containing L0
, L1
and L2
:
A = np.array([L0, L1, L2])
Next we create a numpy array S
:
B = np.array(S)
now we have for C = A[B]
(or C = np.take(A,B,axis=0)
as suggested by @Divakar):
>>> C = np.take(A,B,axis=0)
>>> C
array([[[[b, 0],
[b, b]],
[[b, b],
[b, 1]],
[[b, b],
[2, b]]],
[[[b, b],
[2, b]],
[[b, 0],
[b, b]],
[[b, b],
[b, 1]]]])
, , , : 2D-. , ( swapaxes
, @PaulPanzer), , :
>>> C.transpose(0,2,1,3).reshape(4,6)
array([[b, 0, b, b, b, b],
[b, b, b, 1, 2, b],
[b, b, b, 0, b, b],
[2, b, b, b, b, 1]])
4
6
, , L0
, L1
, L2
S
, :
A = np.array([L0, L1, L2])
B = np.array(S)
m, n = B.shape
_, u, v = A.shape
np.take(A,B,axis=0).swapaxes(1,2).reshape(u*m, v*n)
@DSM, Numpy-1.13 np.block
, :
>>> np.block([[A[i] for i in row] for row in S])
array([[b, 0, b, b, b, b],
[b, b, b, 1, 2, b],
[b, b, b, 0, b, b],
[2, b, b, b, b, 1]])