How can I convert the following numpy A array of form
[[1,2]
[3,4]]
in type B
[[[1,1,1],[2,2,2]]
[[3,3,3],[4,4,4]]]
what can i do element multiplication with C
[[[ 5, 6, 7],[ 8, 9,10]]
[[11,12,13],[13,15,16]]]
?
The original problem is to multiply a scalar by a vector, for example. 4 * [13,15,16]. But instead of a scalar, I have a matrix of scalars (A), and instead of a vector, I have a matrix of vectors (C). If there is a way without real replication of values like in B, I would prefer that (the obvious for-loop will be too slow, I think).
source
share