0

As the title says, I am using numpy and would like to have a (n,1) dimensional vector where each individual element is in fact a matrix.

I have found this answer: Matrix of matrices in python . Based on that post I tried writing the following code:

A,B,C = (np.full((3,3),k) for k in range(3))
D=np.block([[A],[B]])
print(D)
D[1]

However, this does not give me the array A, but instead gives me the first row of array A.

So, is there some way of doing this in numpy?

Thanks

  • Your question isn't really clear. I base this answer on the first line of your post. I don't think you can store numpy ndarray inside other numpy arrays. But, since it's 1D, a list does the trick. Simply create your matrix as np.ndarray and then add them to a list with the append method. – Mathieu Feb 28 '18 at 09:50
  • try this: ```D = np.array([A, B])``` – Irshad Bhat Feb 28 '18 at 09:52
  • @IrshadBhat That works. Thank you very much – Tarabostes Delectus Feb 28 '18 at 09:54

0 Answers0