What am I doing wrong here? I want to element-wise multiply two sparse matrices using Colt. Here's an example of how I'm attempting to do this:
DoubleMatrix2D A = new SparseDoubleMatrix2D(2, 2);
A.set(0, 0, 2.0);
DoubleMatrix2D B = new SparseDoubleMatrix2D(2, 2);
B.set(0, 0, 3.0);
A.assign(B, Functions.mult);
Instead of the expected result of a matrix with 6 as the top left element, I'm getting this:
2 x 2 matrix
18 0
0 0
Changing A to DenseDoubleMatrix2D yields the correct result. Changing B to DenseDoubleMatrix2D does not change the result. Element-wise multiplying two vectors in this fashion always yielded the correct results, no matter whether I used SparseDoubleMatrix1D or DenseDoubleMatrix1D.
"assign" mutates the object, so you may have used it twice.
E.g. See the following code using
Parallel Colt 0.10.0
with the Scala REPL.Or, it could be a bug in a different version you are using of Colt.