numpyのブロックのブロックマトリックスを作成します。

import numpy as np
a=np.random.randint(1,9,size=9).reshape((3,3))
print(a)
b=np.random.randint(1,9,size=3)
print(b)

2つの、ランダムに生成された行列を表示します

#a矩阵
[[4 1 3]
 [7 2 3]
 [5 1 1]]
#b矩阵
[5 3 2]

スプライスbの右側には

b=np.expand_dims(b,axis=0)
print(np.block([[a,b.T]]))

下方にスプライスB

print(np.block([[a],[b]]))


結果

[[4 1 3]
 [7 2 3]
 [5 1 1]
 [5 3 2]]
リリース6元記事 ウォンの賞賛0 ビュー815

おすすめ

転載: blog.csdn.net/Jinyindao243052/article/details/103987955