Sparse matrix ir sorting

4 visualizaciones (últimos 30 días)
Fadime Bekmambetova
Fadime Bekmambetova el 23 de Abr. de 2019
Comentada: Fadime Bekmambetova el 23 de Abr. de 2019
Hi,
I am writing a MEX function and I need to know some specific information about the way sparse matrices are stored: in particular, the result of mxGetIr.
From the documentation on mxSetIr (https://www.mathworks.com/help/matlab/apiref/mxsetir.html) I see the following
"The ir array must be in column-major order. The ir array must define the row positions in column 1 (if any) first, then the row positions in column 2 (if any) second, and so on, through column N. Within each column, row position 1 must appear before row position 2, and so on."
Does this mean that the elements in ir array corresponding to the same column are guaranteed to go in increasing order? This was also my observation but I want to confirm whether this is necessarily the case, so I can use this property in my MEX code.
Thank you!

Respuesta aceptada

James Tursa
James Tursa el 23 de Abr. de 2019
Yes, the elements in the ir array corresponding to the same column are guaranteed to go in increasing order. The indexing is 0-based, not 1-based. If you are building a sparse matrix from scratch in a mex routine, you must ensure this is the case in order to have a valid matrix.
Basically, the elements of the sparse matrix are stored in column-major order in memory ... so the ordering of the ir values for any particular column must be increasing in order for this to be the case.
  1 comentario
Fadime Bekmambetova
Fadime Bekmambetova el 23 de Abr. de 2019
Thank you very much! This clears up a lot of my confusions!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by