Linear Algebra in Siconos

Matrices and vectors handling in kernel component

In Siconos kernel, all matrices and vectors are just interfaces to Eigen vectors and matrices and defined in the files SiconosMatrix.hpp and SiconosVector.hpp.

Please refer to Eigen documentation for details.

Siconos wrappers are:

  • SiconosVector : dense vector of real numbers (type : double precision)

  • BlockVector : vector of SiconosVector

  • SiconosDenseMatrix : dense matrix of double

  • SiconosSparseMatrix : sparse matrix of double, column-major storage.

and some fixed-sized objects, like SiconosMatrix33, SiconosMatrix66 ….

Notice that BlockVector are no more that a collection of pointers to SiconosVector. Then in most cases, to build such an object, you just need to insert some existing objects. The usual ways of construction are described below.

Matrix Storage in numerics component

Numerics component proposes different ways to store ‘matrix-like’ objects, all handled through a C structure, NumericsMatrix .

Numerics component proposes different ways to store ‘matrix-like’ objects, all handled through a C structure, NumericsMatrix .

A number (NumericsMatrix::storageType ) identify the type of storage while only one pointer among NumericsMatrix.matrixX, X = storageType = 0, 1 or 2, is not NULL and hold the values of the matrix.

At the time, the following storages are available:

As an example, consider the following matrix A of size 8X8:

\[\begin{split}\begin{equation*} A=\left[\begin{array}{cccc|cc|cc} 1 & 2 & 0 & 4 & 3 &-1 & 0 & 0\\ 2 & 1 & 0 & 0 & 4 & 1 & 0 & 0\\ 0 & 0 & 1 &-1 & 0 & 0 & 0 & 0\\ 5 & 0 &-1 & 6 & 0 & 6 & 0 & 0\\ \hline 0 & 0 & 0 & 0 & 1 & 0 & 0 & 5\\ 0 & 0 & 0 & 0 & 0 & 2 & 0 & 2\\ \hline 0 & 0 & 2 & 1 & 0 & 0 & 2 & 2\\ 0 & 0 & 2 & 2 & 0 & 0 & -1& 2\\ \end{array}\right] \end{equation*}\end{split}\]

How can we store this matrix ?

The first classical storage results in:

  • M.storageType = 0

  • M.size0 = 8, M.size1 = 8

  • M.matrix0 = [1 2 0 5 0 0 0 0 2 1 0 0 …]

    matrix0 being a double* of size 64.

For the second way of storage, SparseBlockStructuredMatrix we have:

  • M.storageType = 1

  • M.size0 = 8, M.size1 = 8

  • M.matrix1 a SparseBlockStructuredMatrix in which we save:

    • the number of non null blocks, 6 (matrix1->nbblocks) and the number of diagonal blocks, 3 (matrix1->size).

    • the vector matrix1->blocksize which collects the sum of diagonal blocks sizes until the present one, is equal to [4,6,8],

      blocksize[i] = blocksize[i-1] + ni, ni being the size of the diagonal block at row(block) i.

      Note that the last element of blocksize corresponds to the real size of the matrix.

    • the list of positions of non null blocks in vectors matrix1->ColumnIndex and matrix1->RowIndex, equal to [0,1,1,2,0,2] and [0,0,1,1,2,2]

    • the list of non null blocks, in matrix1->block, stored in Fortran order (column-major) as

      matrix1->block[0] = [1,2,0,5,2,1,0,0,0,0,1,-1,4,0,-1,6]

      matrix1->block[1] = [3,4,0,0,-1,1,0,6]

      …

      matrix1->block[5] = [2,-1,2,2]

Todo write proper doc for CSparse storage and complete the example above.

Functions on NumericsMatrix:

Create, fill and delete NumericsMatrix functions:

These last two functions accept a data parameter, which if non-NULL contains the matrix data.

Linear Algebra:

The following linear algebra operation are supported:

-LAPACK-like functions -NM_gesv(): solve a linear system Ax = b

Input / Output: