How operations can be performed if the dimensions of the matrices are different?


#1

I’m trying to do a multiplication of arrays where matrix A is a sparse array 3x3 and matrix x is a sparse array 3x1 using spgemm (A, x) and I get the error:

AFL% spgemm (A, x);

UserException in file: src / linear_algebra / spgemm / LogicalSpgemm.cpp function: inferSchema line: 132
Error id: scidb :: SCIDB_SE_INFER_SCHEMA :: SCIDB_LE_OP_MULTIPLY_ERROR5
Error description: Error during schema inferring. Matrix dimensions must match.

As in the previous question about “matrix subtraction” where I was explained how to do such an operation if the dimensions of the matrix are different maybe it is necessary to realign or remodel them, how is the solution to such a problem?
Because I could not solve it.


#2

Hi @deniscleymaf!
Can you please provide the dimensions of the arrays with which you’re working? You can invoked the following to find them:
filter(list(), name='A'); filter(list(), name='x');
Thank you!
Dave


#3

AFL% filter(list(), name=‘A’);
{No} name,uaid,aid,schema,availability,temporary
{0} ‘A’,388,388,‘A [x=0:3,3,0,y=0:3,3,0]’,true,false

AFL% filter(list(), name=‘x’);
{No} name,uaid,aid,schema,availability,temporary
{20} ‘x’,390,390,‘x [x=0:0,3,0,y=0:2,3,0]’,true,false


#4

Hi @deniscleymaf,
It looks like array x is a 3x1 matrix whereas your array A is a 4x4 matrix, mathematically speaking this multiply won’t work. In your case, you can make the dimensions of your array x be [x=0:0,3,0;y=0:3,3,0] and the multiplication spgemm(x, A) will produce a result. I don’t know if that’s your intent, or if the array A should be a 3x3 matrix instead; that depends on what you’re trying to compute.
Please let me know if I can help further.
Thanks!
Dave