SparseBlockMatrix (functions)


siconos.numerics.SBCM_free_3x3(SparseBlockCoordinateMatrix *MC) → None[source]

free allocated memory in newSparseBlockCoordinateMatrix functions

Parameters:MC – matrix pointer

siconos.numerics.SBCM_new(None) → SparseBlockCoordinateMatrix *[source]

siconos.numerics.SBCM_new_3x3(int m, int n, int nbblocks, int *row, int *column, array_like (np.float64, 1D)block) → SparseBlockCoordinateMatrix *[source]

allocate a SparseBlockCoordinateMatrix from a list of 3x3 blocks

Parameters:
  • m – the number of rows
  • n – the number of colums
  • nbblocks – the number of blocks
  • row – a pointer to row of each block
  • column – a pointer to column of each block
  • block – a pointer to each block
Returns:

a pointer to a SparseBlockCoordinateMatrix structure


siconos.numerics.SBCM_null(SparseBlockCoordinateMatrix *MC) → None[source]

siconos.numerics.SBCM_to_SBM(SparseBlockCoordinateMatrix *MC) → SparseBlockStructuredMatrix *[source]

copy a SparseBlockCoordinateMatrix to a SparseBlockStructuredMatrix

Parameters:MC – the SparseBlockCoordinateMatrix matrix
Returns:a pointer to a SparseBlockCoordinateMatrix structure

siconos.numerics.SBM_add(SparseBlockStructuredMatrix *A, SparseBlockStructuredMatrix *B, double alpha, double beta) → SparseBlockStructuredMatrix *[source]

SparseBlockStructuredMatrix - SparseBlockStructuredMatrix addition C = alpha*A + beta*B.

Parameters:
  • A – the matrix to be added
  • B – the matrix to be added
  • alpha – coefficient
  • beta – coefficient
Returns:

C the resulting matrix


siconos.numerics.SBM_add_without_allocation(SparseBlockStructuredMatrix *A, SparseBlockStructuredMatrix *B, double alpha, double beta, SparseBlockStructuredMatrix *C, double gamma) → None[source]

SparseBlockStructuredMatrix - SparseBlockStructuredMatrix addition C = alpha*A + beta*B + gamma*C without allocation We assume that C has the correct structure.

Parameters:
  • A – the matrix to be added
  • B – the matrix to be added
  • alpha – coefficient
  • beta – coefficient
  • gamma – coefficient
  • C – the resulting matrix

siconos.numerics.SBM_column_permutation(int *colarray_like (int, 1D), SparseBlockStructuredMatrix *A, SparseBlockStructuredMatrix *C) → None[source]

siconos.numerics.SBM_copy(SparseBlockStructuredMatrix * A, SparseBlockStructuredMatrix *B, int copyBlock) → int[source]

Copy of a SBM A into B.

Parameters:
  • A – the SparseBlockStructuredMatrix matrix to be copied
  • B – the SparseBlockStructuredMatrix matrix copy of A
  • copyBlock – if copyBlock then the content of block are copied, else only the pointers are copied.
Returns:

0 if ok


siconos.numerics.SBM_diagonal_block_index(SparseBlockStructuredMatrix * M, int row) → int[source]

Find index of the diagonal block in a row.

Parameters:
  • M – the SparseBlockStructuredMatrix matrix
  • row – the row of the required block
Returns:

pos the position of the block


siconos.numerics.SBM_diagonal_block_indices(SparseBlockStructuredMatrix * M) → int *[source]

Compute the indices of blocks of the diagonal block.

Parameters:M – the SparseBlockStructuredMatrix matrix
Returns:the indices for all the rows

siconos.numerics.SBM_extract_component_3x3(SparseBlockStructuredMatrix * A, SparseBlockStructuredMatrix *B, int *row_components, int row_components_size, int *col_components, int col_components_size) → None[source]

siconos.numerics.SBM_free(SparseBlockStructuredMatrix *blmat) → None[source]

Destructor for SparseBlockStructuredMatrix objects.

Parameters:blmat – SparseBlockStructuredMatrix the matrix to be destroyed.

siconos.numerics.SBM_free_from_SBCM(SparseBlockStructuredMatrix *M) → None[source]

free a SparseBlockStructuredMatrix created with SBCM_to_SBM

Parameters:M – a SparseBlockStructuredMatrix to free

siconos.numerics.SBM_free_pred(SparseBlockStructuredMatrixPred *blmatpred) → None[source]

Destructor for SparseBlockStructuredMatrixPred objects.

Parameters:blmatpred – SparseBlockStructuredMatrix, the matrix to be destroyed.

siconos.numerics.SBM_from_csparse(int blocksize, CSparseMatrix * sparseMat, SparseBlockStructuredMatrix *outSBM) → int[source]

Copy a Sparse Matrix into a SBM, with fixed blocksize.

Parameters:
  • blocksize – the blocksize
  • sparseMat – pointer on the Sparse Matrix
  • outSBM – pointer on an empty SparseBlockStructuredMatrix
Returns:

0 in ok


siconos.numerics.SBM_gemm_without_allocation(double alpha, SparseBlockStructuredMatrix * A, SparseBlockStructuredMatrix * B, double beta, SparseBlockStructuredMatrix *C) → None[source]

SparseBlockStructuredMatrix - SparseBlockStructuredMatrix product C = alpha*A*B + beta*C The routine has to be used with precaution.

The allocation of C is not done since we want to add beta*C. We assume that the structure and the allocation of the matrix C are right. Especially:

  • the blocks C(i,j) must exists

  • the sizes of blocks must be consistent

  • no extra block must be present in C

    Parameters:

    alpha :

    coefficient

    A :

    the matrix to be multiplied

    B :

    the matrix to be multiplied

    beta :

    coefficient

    C :

    the resulting matrix


siconos.numerics.SBM_gemv(int sizeX, int sizeY, double alpha, SparseBlockStructuredMatrix * A, array_like (np.float64, 1D)x, double beta, array_like (np.float64, 1D)y) → None[source]

SparseMatrix - vector product y = alpha*A*x + beta*y.

Parameters:
  • sizeX – dim of the vectors x
  • sizeY – dim of the vectors y
  • alpha – coefficient
  • A – the matrix to be multiplied
  • x – the vector to be multiplied
  • beta – coefficient
  • y – the resulting vector

siconos.numerics.SBM_gemv_3x3(int sizeX, int sizeY, SparseBlockStructuredMatrix * A, array_like (np.float64, 1D) x, array_like (np.float64, 1D)y) → None[source]

SparseMatrix - vector product y = A*x + y for block of size 3x3.

Parameters:
  • sizeX – dim of the vectors x
  • sizeY – dim of the vectors y
  • A – the matrix to be multiplied
  • x – the vector to be multiplied
  • y – the resulting vector

siconos.numerics.SBM_get_value(SparseBlockStructuredMatrix * M, int row, int col) → double[source]

get the element of row i and column j of the matrix M

Parameters:
  • M – the SparseBlockStructuredMatrix matrix
  • row – the row index
  • col – the column index
Returns:

the value


siconos.numerics.SBM_inverse_diagonal_block_matrix_in_place(SparseBlockStructuredMatrix *M, int *ipiv) → int[source]

Inverse (in place) a square diagonal block matrix.

Parameters:
  • M – the SparseBlockStructuredMatrix matrix to be inversed
  • ipiv – worksapce for storign ipiv
Returns:

0 ik ok


siconos.numerics.SBM_multiply(SparseBlockStructuredMatrix * A, SparseBlockStructuredMatrix * B) → SparseBlockStructuredMatrix *[source]

SparseBlockStructuredMatrix - SparseBlockStructuredMatrix multiplication C = A *B Correct allocation is performed.

Parameters:
  • A – the matrix to be multiplied
  • B – the matrix to be multiplied
Returns:

C the resulting matrix


siconos.numerics.SBM_new(None) → SparseBlockStructuredMatrix *[source]

Creation of an empty Sparse Block Matrix.

Returns:a pointer on allocated and initialized space

siconos.numerics.SBM_new_from_file(FILE *file) → SparseBlockStructuredMatrix *[source]

Create from file a SparseBlockStructuredMatrix with memory allocation.

Parameters:file – the corresponding name of the file
Returns:the matrix to be displayed

siconos.numerics.SBM_null(SparseBlockStructuredMatrix *sbm) → None[source]

set Sparse Block Matrix.

fields to NULL

Parameters:sbm – a matrix

siconos.numerics.SBM_print(SparseBlockStructuredMatrix * m) → None[source]

Screen display of the matrix content.

Parameters:m – the matrix to be displayed

siconos.numerics.SBM_read_in_file(SparseBlockStructuredMatrix * M, FILE *file) → None[source]

read in file of the matrix content without performing memory allocation

Parameters:
  • M – the matrix to be displayed
  • file – the corresponding name of the file

siconos.numerics.SBM_read_in_filename(SparseBlockStructuredMatrix * M, char *filename) → None[source]

read in file of the matrix content

Parameters:
  • M – the matrix to be displayed
  • filename – the corresponding name of the file

siconos.numerics.SBM_row_permutation(int *rowarray_like (int, 1D), SparseBlockStructuredMatrix *A, SparseBlockStructuredMatrix *C) → None[source]

siconos.numerics.SBM_row_prod(int sizeX, int sizeY, int currentRowNumber, SparseBlockStructuredMatrix * A, array_like (np.float64, 1D) x, array_like (np.float64, 1D)y, int init) → None[source]

Row of a SparseMatrix - vector product y = rowA*x or y += rowA*x, rowA being a row of blocks of A.

Parameters:
  • sizeX – dim of the vector x
  • sizeY – dim of the vector y
  • currentRowNumber – number of the required row of blocks
  • A – the matrix to be multiplied
  • x – the vector to be multiplied
  • y – the resulting vector
  • init – = 0 for y += Ax, =1 for y = Ax

siconos.numerics.SBM_row_prod_no_diag(int sizeX, int sizeY, int currentRowNumber, SparseBlockStructuredMatrix * A, array_like (np.float64, 1D) x, array_like (np.float64, 1D)y, int init) → None[source]

Row of a SparseMatrix - vector product y = rowA*x or y += rowA*x, rowA being a row of blocks of A.

Parameters:
  • sizeX – dim of the vector x
  • sizeY – dim of the vector y
  • currentRowNumber – number of the required row of blocks
  • A – the matrix to be multiplied
  • x – the vector to be multiplied
  • y – the resulting vector
  • init – = 0 for y += Ax, =1 for y = Ax

siconos.numerics.SBM_row_prod_no_diag_1x1(int sizeX, int sizeY, int currentRowNumber, SparseBlockStructuredMatrix * A, array_like (np.float64, 1D) x, array_like (np.float64, 1D)y) → None[source]

siconos.numerics.SBM_row_prod_no_diag_3x3(int sizeX, int sizeY, int currentRowNumber, SparseBlockStructuredMatrix * A, array_like (np.float64, 1D) x, array_like (np.float64, 1D)y) → None[source]

Row of a SparseMatrix - vector product y = rowA*x or y += rowA*x, rowA being a row of blocks of A of size 3x3.

Parameters:
  • sizeX – dim of the vector x
  • sizeY – dim of the vector y
  • currentRowNumber – number of the required row of blocks
  • A – the matrix to be multiplied
  • x – the vector to be multiplied
  • y – the resulting vector

siconos.numerics.SBM_to_dense(SparseBlockStructuredMatrix * A, array_like (np.float64, 1D)denseMat) → None[source]

Copy a SBM into a Dense Matrix.

Parameters:
  • A – the SparseBlockStructuredMatrix matrix
  • denseMat – pointer on the filled dense Matrix

siconos.numerics.SBM_to_sparse(SparseBlockStructuredMatrix * A, CSparseMatrix *outSparseMat) → int[source]

Copy a SBM into a Sparse (CSR) Matrix.

Parameters:
  • A – the SparseBlockStructuredMatrix matrix
  • outSparseMat – pointer on the filled sparse Matrix
Returns:

0 if ok


siconos.numerics.SBM_to_sparse_init_memory(SparseBlockStructuredMatrix * A, CSparseMatrix *sparseMat) → int[source]

initMemory of a Sparse (CSR) Matrix form a SBM matrix

Parameters:
  • A – the SparseBlockStructuredMatrix matrix
  • sparseMat – pointer on the initialized sparse Matrix
Returns:

0 if ok


siconos.numerics.SBM_transpose(SparseBlockStructuredMatrix * A, SparseBlockStructuredMatrix *B) → int[source]

Transpose by copy of a SBM A into B.

Parameters:
  • A – the SparseBlockStructuredMatrix matrix to be copied
  • B – the SparseBlockStructuredMatrix matrix copy of transpose A
Returns:

0 if ok


siconos.numerics.SBM_write_in_file(SparseBlockStructuredMatrix * m, FILE *file) → None[source]

print in file of the matrix content

Parameters:
  • m – the matrix to be displayed
  • file – the corresponding file

siconos.numerics.SBM_write_in_fileForScilab(SparseBlockStructuredMatrix * M, FILE *file) → None[source]

print in file of the matrix content in Scilab format for each block

Parameters:
  • M – the matrix to be displayed
  • file – the corresponding file

siconos.numerics.SBM_write_in_filename(SparseBlockStructuredMatrix * M, char *filename) → None[source]

print in file of the matrix content

Parameters:
  • M – the matrix to be displayed
  • filename – the corresponding file

siconos.numerics.SBM_zentry(SparseBlockStructuredMatrix * M, int row, int col, double val) → int[source]

siconos.numerics.SBM_zero_matrix_for_multiply(SparseBlockStructuredMatrix * A, SparseBlockStructuredMatrix * B) → SparseBlockStructuredMatrix *[source]

Perform the allocation of a zero matrix that is compatible qith multiplication.


siconos.numerics.SBMfree(SparseBlockStructuredMatrix *A, int level) → None[source]

To free a SBM matrix (for example allocated by NM_new_from_file).

Parameters:
  • A – the SparseBlockStructuredMatrix that mus be de-allocated.
  • level – use NUMERICS_SBM_FREE_BLOCK | NUMERICS_SBM_FREE_SBM