Dear Masters,

Given this sparse matrix representation:

`my @realval = (
0.994704478,
0.989459074,
0.994717023,
1.000000000,
1.000000000,
0.002647761,
0.005282977,
0.000882587,
0.005270463,
0.000882587,
0.002635231,
0.000882587,
0.002635231,);
my @row_index = qw( 1 2 3 4 5 1 3 1 2 1 2 1 2);
my @col_index = qw(1 2 3 4 5 5 3 2 1 3 3 4 4);
my @mat_dim = (5,5); # M always equal to N
`

I have no problem generating the actual matrix like this:

` my @actual_mat = (
[ 0.994704478, 0.000882587, 0.000882587, 0.000882587, 0.002647761],
[ 0.005270463, 0.989459074, 0.002635231, 0.002635231, 0.000000000],
[ 0.000000000, 0.000000000, 0.005282977, 0.000000000, 0.000000000].
[ 0.000000000, 0.000000000, 0.000000000, 1.000000000, 0.000000000],
[ 0.000000000, 0.000000000, 0.000000000, 0.000000000, 1.000000000]
);
# It is simply done by assigning the value in @real_value given
# the corresponding (@row,@index) as coordinate;
# e.g. to assign $real_value[-1] into
# $actual_mat[$row_index[-1]-1,$col_index[-1]-1);
`

My question is: can we do matrix multiplication by just using sparse
matrix representation above instead of

`@actual_mat`.

Given the multiplicator

`my @p = (0.4,0.2,0.2,0.2,0.2);
`

we expect to get from

`p * SparseM`
`my $result = [
0.3989409,
0.2010541,
0.2000000,
0.2000000,
0.2000000,
];
`

---

*neversaint and everlastingly indebted.......*

Comment onSparse Matrix Multiplication ProblemSelectorDownloadCode