 # Spgemm result lacks the first value

#1

Good evening!

I am trying a simple matrix multiplication, however there is an element missing form the answer. This is how I prepare for the multiplication:

``````set lang aql;
CREATE ARRAY A<val:double> [row=0:1,2,0, col=0:2,3,0];
CREATE ARRAY B<val:double> [row=0:1,2,0, col=0:2,3,0];
INSERT INTO A '[[(0) (1) (2)] [(2) (3) (4)]]';
INSERT INTO B '[[(1) (0) (0)] [(2) (-3) (1)]]';

set lang afl;

Then, when I run the matrix multiplication, the position {0,0} is missing from the answer

``````spgemm(A, transpose(B));
{row,row2} multiply
{0,1} -1
{1,0} 2
{1,1} -1``````

Am I doing something wrong?

Thanks!

#2

Hello!

For any values that are calculated to be the additive identity (0 for regular arithmetic), spgemm outputs an “empty cell”. This is the reason the output appears to be missing an element.

If you need the explicit “0” in the output, please use merge():

``````merge(spgemm(A, transpose(B)), build(<a:double> [row=0:1,2,0, col=0:1,2,0], 0))
{row,row2} multiply
{0,0} 0
{0,1} -1
{1,0} 2
{1,1} -1``````
• Sunny