1

import cern.colt.matrix.*;

I have a huge square sparse matrix (say 30k*30k) and I need to get non-zero elements of a specific row (to do some complicated math in a nested loop). The method forEachNonZero(IntIntDoubleFunction function) is probably not good enough because it goes through every non-zero element of the matrix.

SparseDoubleMatrix2D has a method viewRow (inherited from DoubleMatrix2D) which returns DoubleMatrix1D. But this is still not good enough because with DoubleMatrix1D I have to go through every single elements in the row to find non-zero elements.

aaronqli
  • 790
  • 9
  • 26
  • Did you solve this issue? I need something similar: get the means of the sparse matrix columns. – b3rt0 Nov 28 '19 at 09:18

0 Answers0