Skip to content
Joris Gillis edited this page Sep 15, 2022 · 1 revision

Standard documentation for Sparsity:

 General sparsity class.

The storage format is a compressed column storage (CCS) format. In this format, the structural non-zero elements are stored in column-major order, starting from the upper left corner of the matrix and ending in the lower right corner.

In addition to the dimension ( size1(), size2()), (i.e. the number of rows and the number of columns respectively), there are also two vectors of integers:

"colind" [length size2()+1], which contains the index to the first non- zero element on or after the corresponding column. All the non-zero elements of a particular i are thus the elements with index el that fulfills: colind[i] <= el < colind[i+1].

"row" [same length as the number of non-zero elements, nnz()] The rows for each of the structural non-zeros.

Note that with this format, it is cheap to loop over all the non-zero

elements of a particular column, at constant time per element, but

expensive to jump to access a location (i, j).

If the matrix is dense, i.e. length(row) == size1()*size2(), the format reduces to standard dense column major format, which allows access to an arbitrary element in constant time.

Since the object is reference counted (it inherits from SharedObject), several matrices are allowed to share the same sparsity pattern.

The implementations of methods marked as such in this class has been taken from the CSparse package and modified to fit CasADi data structures and separation of sparsity pattern calculation and numerical evaluation. These functions are Copyright(c) Timothy A. Davis, 2006-2009 and licensed as a derivative work under the GNU LGPL

See: Matrix

Joel Andersson

Extra doc: https://github.com/casadi/casadi/wiki/L_b9

C++ includes: sparsity.hpp

Extra documentation

To edit, see writing tips.

Clone this wiki locally