File numerics/src/tools/NumericsSparseMatrix.h

Go to the source code of this file

Data structures and functions for sparse matrices.

Typedefs

typedef void (*freeNSLSP)(void *p)
typedef struct linalg_data_t linalg_data_t

Enums

enum linalg_data_id

Values:

SN_LINALG_UNKNOWN
SN_LINALG_MKL
enum NSM_linear_solver

NumericsSparseMatrix.h id for linear algebra solvers.

Values:

NSM_CS_LUSOL
NSM_MUMPS
NSM_UMFPACK
NSM_MKL_PARDISO
NSM_SUPERLU
NSM_SUPERLU_MT
enum NumericsSparseOrigin

NumericsSparseMatrix.h matrix storage types.

Values:

NSM_UNKNOWN
NSM_TRIPLET
NSM_CSC
NSM_CSR
enum NumericsSparseTypesNZ

value of nz for some matrix storage type

Values:

NSM_CS_CSC = -1
NSM_CS_CSR = -2

Functions

double *NSM_data(NumericsSparseMatrix *A)

Get the data part of sparse matrix.

Return
a pointer to the data array
Parameters
  • A: the sparse matrix

CS_INT *NSM_diag_indices(NumericsMatrix *M)

return the set of indices corresponding to the diagonal elements of the matrix

Warning
should be better tested
Return
the list of indices for the diagonal elements
Parameters
  • M: the matrix

void NSM_extract_block(NumericsMatrix *M, double *blockM, size_t pos_row, size_t pos_col, size_t block_row_size, size_t block_col_size)

Extract a block from a sparse matrix.

Parameters
  • M: matrix
  • blockM: dense storage for the block
  • pos_row: starting row for the block
  • pos_col: starting column for the block
  • block_row_size: block width
  • block_col_size: block height

void NSM_fix_csc(CSparseMatrix *A)

Check and fix a matrix, if needed.

Parameters
  • A: the matrix to check, modified if necessary to have ordered indices

NumericsSparseMatrix *NSM_free(NumericsSparseMatrix *A)

Free allocated space for a NumericsSparseMatrix.

Return
NULL on success
Parameters

void NSM_free_p(void *p)

Free a workspace related to a LU factorization.

Parameters
  • p: the structure to free

CSparseMatrix *NSM_get_origin(const NumericsSparseMatrix *M)

return the sparse matrix that has the original label

Return
the sparse matrix that is at the origin, or NULL if an error occur
Parameters
  • M: the matrix

NSM_linear_solver_params *NSM_linearSolverParams(NumericsMatrix *A)

Get linear solver parameters with initialization if needed.

Return
a pointer on parameters.
Parameters

NSM_linear_solver_params *NSM_linearSolverParams_free(NSM_linear_solver_params *p)

Free allocated space for NSM_linear_solver_params.

Return
NULL on success
Parameters

NSM_linear_solver_params *NSM_linearSolverParams_new(void)

New and empty NSM_linear_solver_params.

Return
a pointer on the allocated space.

NumericsSparseMatrix *NSM_new(void)

New and empty NumericsSparseMatrix with correctly initialized fields.

Return
a pointer on the allocated space.

NumericsSparseMatrix *NSM_new_from_file(FILE *file)

New and empty NumericsSparseMatrix with correctly initialized fields.

Return
a pointer on the allocated space.

size_t NSM_nnz(const CSparseMatrix *const A)

get the number of non-zero (nnz) in a sparse matrix

Return
the number of non-zero elements in the matrix
Parameters
  • A: the matrix

void NSM_null(NumericsSparseMatrix *A)

Initialize the fields of a NumericsSparseMatrix.

Parameters
  • A: the sparse matrix

unsigned NSM_origin(const NumericsSparseMatrix *M)

return the origin of a sparse part of a matrix

Return
-1 if the matrix has no sparse representation, the origin otherwise
Parameters
  • M: the matrix

static void *NSM_solver_data(NSM_linear_solver_params *p)

Get the LU factors for cs_lusol.

Parameters
  • p: the structure holding the data for the solver

int NSM_to_dense(const NumericsSparseMatrix *const A, double *B)
NumericsSparseMatrix *NSM_triplet_eye(unsigned int size)
static double *NSM_workspace(NSM_linear_solver_params *p)

Get the workspace for the sparse solver.

Return
the (double) workspace
Parameters
  • p: the structure holding the data for the solver

void NSM_write_in_file(const NumericsSparseMatrix *m, FILE *file)
struct linalg_data_t
#include <NumericsSparseMatrix.h>

generic data struct for linear algebra operations

Public Members

void (*free_fn)(struct linalg_data_t *)
int id
struct NSM_linear_solver_params
#include <NumericsSparseMatrix.h>

solver-specific parameters

Public Members

double *dWork
int dWorkSize
int *iWork

integer work vector array (internal)

int iWorkSize

size of integer work vector array

linalg_data_t *linalg_data

data for the linear algebra

NSM_linear_solver solver
void *solver_data

solver-specific data (or workspace)

freeNSLSP solver_free_hook

solver-specific hook to free solver_data

struct NumericsSparseMatrix
#include <NumericsSparseMatrix.h>

Sparse matrix representation in Numerics.

The supported format are: triplet (aka coordinate, COO), CSC (via CSparse) and CSR if MKL is used

Public Members

CSparseMatrix *csc

csc matrix

CSparseMatrix *csr

csr matrix, only supported with mkl

CS_INT *diag_indx

indices for the diagonal terms.

Very useful for the proximal perturbation

NSM_linear_solver_params *linearSolverParams

solver-specific parameters

unsigned origin

original format of the matrix

CSparseMatrix *trans_csc

transpose of a csc matrix (used by CSparse)

CSparseMatrix *triplet

triplet format, aka coordinate