java - Matrix multiplication using Jblas: Matrices need to have same length -
i using java + jblas (first time user) , trying multiply 2 matrices. 1 163x4 , other 4x1 matrix. expect result of such multiplication 163x1 matrix. using:
floatmatrix = b.mmuli(c);
i getting error:
matrices must have same length (is: 652 , 4)
now while assume, makes perfect sense program confused. same multiplication worked fine in octave (which of course applies magic). getting work need know kind of sorcery is?
edit
so here octave documentation says broadcasting (the sorcery):
in case dimensions equal, no broadcasting occurs , ordinary element-by-element arithmetic takes place. arrays of higher dimensions, if number of dimensions isn’t same, missing trailing dimensions treated 1. when 1 of dimensions 1, array singleton dimension gets copied along dimension until matches dimension of other array.
so means copy 4x1 matrix 163 times. can execute multiplication, instead of 163x1 matrix wanted, have 163x4 matrix. me strange. solution now?
so figured out. , it's 1 of mistakes... has be
floatmatrix = b.mmul(c);
the element wise multiplication error here.
Comments
Post a Comment