从numpy中的较小矩阵创建较大的矩阵 [英] Create a larger matrix from smaller matrices in numpy

查看:268
本文介绍了从numpy中的较小矩阵创建较大的矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个矩阵A,B,C.我希望创建一个更大的表格形式

I have 3 matrices A,B,C. I wish to create a larger matrix of the form

D = | 0 A |
    | B C |

如何在Numpy中执行此操作?

How to do this in Numpy ?

推荐答案

此:

numpy.bmat([[numpy.zeros(appropriate_shape), A], [B, C]])

可行,但是我不确定如何避免创建大的,无用的零数组.另外,它返回的是矩阵而不是数组,因此如果需要数组,请确保在其上调用asarray.

works, but I'm not sure how to avoid the creation of that big, useless array of zeros. Also, it returns a matrix instead of an array, so make sure to call asarray on it if you want an array.

这篇关于从numpy中的较小矩阵创建较大的矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆