Issue
I would like the create the following numpy array, based on the following vector
e = numpy.array([1,0,0,0,0,0])
a = [ [e, 0, ---, 0],
[0, e, ---, 0],
-
-
[0, 0, ---, e]]
(Note: The 0
in this array is thus a zero vector and not scalar)
and thus;
a = [ [1,0,0,0,0,0, 0,0,0,0,0,0, ---, 0,0,0,0,0,0],
[0,0,0,0,0,0, 1,0,0,0,0,0, ---, 0,0,0,0,0,0],
-
-
[0,0,0,0,0,0, 0,0,0,0,0,0 ---, 1,0,0,0,0,0]]
The solutions does not have to make use of e
. The structure of the first array (based on e
) is due the underlying linear algebra of the problem I'm tackling.
I have looked at tile and repeat from numpy. However, I was not able to create a
with these functions. Ideally, I would like to use a numpy function as speed is quite important for my implementation.
EDIT: e
is an numpy array and not a python list
EDIT: added some extra information
Solution
Initially the suggestion from 'Michael Szczesny', was the one I ended up using. However, I found out as well that the Kronecker product is the mathematical operation which I was looking for.
From this StackOverflow answer it seems(/seemed) that the SciPy implementation works better than the NumPy one. This answer is quite old (2013). However, I do not have enough reputation to ask a followup question.
Maybe someone else would benefit from this information
Answered By - HerChip
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.