I have some problem with matrix multiplication:
I want to multiplicate for example a and b:
a=array([1,3]) # a is random and is array!!! (I have no impact on that)
# there is a just for example what I want to do...
b=[[[1], [2]], #b is also random but always size(b)= even
[[3], [2]],
[[4], [6]],
[[2], [3]]]
So what I want is to multiplicate in this way
[1,3]*[1;2]=7
[1,3]*[3;2]=9
[1,3]*[4;6]=22
[1,3]*[2;3]=11
So result what I need will look:
x1=[7,9]
x2=[22,8]
I know is very complicated but I try 2 hours to implement this but without success :(
Your b seem to have an unnecessary dimension.
With proper b you can just use dot(.), like:
In []: a
Out[]: array([1, 3])
In []: b
Out[]:
array([[1, 2],
[3, 2],
[4, 6],
[2, 3]])
In []: dot(b, a).reshape((2, -1))
Out[]:
array([[ 7, 9],
[22, 11]])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With