MATLAB Answers

0

Are the values in each compressed column of a sparse matrix stored in order?

Asked by Oliver Woodford on 20 Nov 2015
Latest activity Answered by Oliver Woodford on 20 Nov 2015
If I have a sparse column vector (e.g. a column of a sparse matrix), and I'm accessing the elements of that vector in a mex file, are the row indices guaranteed to be sorted in order, lowest row index first?

  0 Comments

Sign in to comment.

Products

1 Answer

Answer by Oliver Woodford on 20 Nov 2015

Since it is possible to write the column data in any order from a mex file, I would say no.
However, I tried three methods of sparse matrix generation:
  • sparse(ceil(rand(10000, 1)*1000), ceil(rand(10000, 1)*1000), 1, 1000, 1000)
  • sprand(1000, 1000, 0.01)
  • sparse(A)
and these all provided sorted columns.

  0 Comments

Sign in to comment.