import numpy as np a0 = np.zeros((2,6,8), dtype=np.float64) x = np.array([-2*x for x in range(1, 4)]) # 1x3 の行列 y = np.array([[-2*(i+j) for j in range(3)] for i in range(4)]) # 4x3 の行列 print('a0(繧ェ繝ェ繧ク繝翫Ν) = ', a0) a0[1,1:4,3] = x print('a0(x繧剃サ」蜈・) = ', a0) a0[0,0:4,0:3] = y print('a0(y繧剃サ」蜈・) = ', a0)
a0(オリジナル) = [[[ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.]] [[ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.]]] a0(xを代入) = [[[ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.]] [[ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. -2. 0. 0. 0. 0.] [ 0. 0. 0. -4. 0. 0. 0. 0.] [ 0. 0. 0. -6. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.]]] a0(yを代入) = [[[ 0. -2. -4. 0. 0. 0. 0. 0.] [ -2. -4. -6. 0. 0. 0. 0. 0.] [ -4. -6. -8. 0. 0. 0. 0. 0.] [ -6. -8. -10. 0. 0. 0. 0. 0.] [ 0. 0. 0.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