File numerics/src/tools/NumericsSparseMatrix.h

Contents

File numerics/src/tools/NumericsSparseMatrix.h#

Go to the source code of this file

Data structures and functions for sparse matrices

Typedefs

typedef struct linalg_data_t linalg_data_t#
typedef void (*freeNSLSP)(void *p)#
typedef NumericsSparseOrigin NSM_t#

Enums

enum linalg_data_id#

Values:

enumerator SN_LINALG_UNKNOWN#
enumerator SN_LINALG_MKL#
enum NSM_linear_solver#

NumericsSparseMatrix.h id for linear algebra solvers.

Values:

enumerator NSM_CSPARSE#
enumerator NSM_MUMPS#
enumerator NSM_UMFPACK#
enumerator NSM_MKL_PARDISO#
enumerator NSM_SUPERLU#
enumerator NSM_SUPERLU_MT#
enumerator NSM_HSL#
enum NumericsSparseTypesNZ#

value of nz for some matrix storage type

Values:

enumerator NSM_CS_CSC#
enumerator NSM_CS_CSR#
enum NumericsSparseOrigin#

NumericsSparseMatrix.h matrix storage types.

Values:

enumerator NSM_UNKNOWN#
enumerator NSM_TRIPLET#
enumerator NSM_CSC#
enumerator NSM_CSR#
enumerator NSM_HALF_TRIPLET#

Functions

void NSM_null(NumericsSparseMatrix *A)#

Initialize the fields of a NumericsSparseMatrix.

Parameters:

A – the sparse matrix

NumericsSparseMatrix *NSM_new(void)#

New and empty NumericsSparseMatrix with correctly initialized fields.

Returns:

a pointer on the allocated space.

NumericsSparseMatrix *NSM_triplet_eye(unsigned int size)#
NumericsSparseMatrix *NSM_triplet_scalar(unsigned int size, double s)#
NumericsSparseMatrix *NSM_clear(NumericsSparseMatrix *A)#

Free allocated space for a NumericsSparseMatrix.

Parameters:

A – a NumericsSparseMatrix

Returns:

NULL on success

void NSM_version_copy(const NumericsSparseMatrix *const A, NumericsSparseMatrix *B)#

Copy NumericsSparseMatrix version.

Parameters:
void NSM_copy(NumericsSparseMatrix *A, NumericsSparseMatrix *B)#

Copy a NumericsSparseMatrix.

Parameters:
void NSM_clear_p(void *p)#

Free a workspace related to a LU factorization.

Parameters:

p – the structure to free

double *NSM_data(NumericsSparseMatrix *A)#

Get the data part of sparse matrix.

Parameters:

A – the sparse matrix

Returns:

a pointer to the data array

static inline void *NSM_linear_solver_data(NSM_linear_solver_params *p)#

Get the LU factors for cs_lusol.

Parameters:

p – the structure holding the data for the solver

static inline double *NSM_workspace(NSM_linear_solver_params *p)#

Get the workspace for the sparse solver.

Parameters:

p – the structure holding the data for the solver

Returns:

the (double) workspace

size_t NSM_nnz(const CSparseMatrix *const A)#

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

Parameters:

A – the matrix

Returns:

the number of non-zero elements in the 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

Parameters:

M – the matrix

Returns:

the list of indices for the diagonal elements

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

NSM_linear_solver_params *NSM_linearSolverParams_free(NSM_linear_solver_params *p)#

Free allocated space for NSM_linear_solver_params.

Parameters:

p – a NSM_linear_solver_params

Returns:

NULL on success

NSM_linear_solver_params *NSM_linearSolverParams_new(void)#

New and empty NSM_linear_solver_params.

Returns:

a pointer on the allocated space.

NSM_linear_solver_params *NSM_linearSolverParams(NumericsMatrix *A)#

Get linear solver parameters with initialization if needed.

Parameters:

A[inout] a NumericsMatrix.

Returns:

a pointer on parameters.

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

void NSM_sort_csc(CSparseMatrix *A)#
unsigned NSM_origin(const NumericsSparseMatrix *M)#

return the origin of a sparse part of a matrix

Parameters:

M – the matrix

Returns:

-1 if the matrix has no sparse representation, the origin otherwise

CSparseMatrix *NSM_get_origin(const NumericsSparseMatrix *M)#

return the sparse matrix that has the original label

Parameters:

M – the matrix

Returns:

the sparse matrix that is at the origin, or NULL if an error occur

void NSM_write_in_file(const NumericsSparseMatrix *m, FILE *file)#
NumericsSparseMatrix *NSM_new_from_file(FILE *file)#

New and empty NumericsSparseMatrix with correctly initialized fields.

Returns:

a pointer on the allocated space.

int NSM_to_dense(const NumericsSparseMatrix *const A, double *B)#
version_t NSM_version(const NumericsSparseMatrix *M, NSM_t type)#

Get current version of a type of csparse matrix.

Parameters:
Returns:

a comparable version.

version_t NSM_max_version(const NumericsSparseMatrix *M)#

Get the maximum of versions of csparse matrices.

Parameters:

M – the NumericsSparseMatrix,

Returns:

a comparable version.

void NSM_set_version(NumericsSparseMatrix *M, NSM_t type, version_t value)#

Set the version of a NumericsSparseMatrix.

Parameters:
  • M – the NumericsSparseMatrix,

  • type – the NumericsSparseOrigin of storage,

  • value – the new version.

void NSM_reset_versions(NumericsSparseMatrix *M)#

Reset all versions of a NumericsSparseMatrix.

Parameters:

M – the NumericsSparseMatrix.

void NSM_reset_version(NumericsSparseMatrix *M, NSM_t type)#

Reset version of a sparse storage.

Parameters:
void NSM_inc_version(NumericsSparseMatrix *M, NSM_t type)#

Increment the version of a NumericsSparseMatrix.

Parameters:
NSM_t NSM_latest_id(const NumericsSparseMatrix *M)#

Get the NumericsSparseOrigin with the latest version.

Parameters:

M – the NumericsSparseMatrix

Returns:

the NumericsSparseOrigin.

CSparseMatrix *NSM_latest(const NumericsSparseMatrix *M)#

Get most recent CSparseMatrix.

Parameters:

M – the NumericsSparseMatrix

Returns:

a pointer on a CSparseMatrix.

void NSM_version_sync(NumericsSparseMatrix *M)#

Sync matrix origin and version.

Parameters:

M – the NumericsSparseMatrix

struct linalg_data_t
#include <NumericsSparseMatrix.h>

generic data struct for linear algebra operations

Public Members

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

solver-specific parameters

Public Members

NumericsMatrix *parent_matrix#
NSM_linear_solver solver#
NSM_linear_solver LDLT_solver#
void *linear_solver_data#

solver-specific data (or workspace)

freeNSLSP solver_free_hook#

solver-specific hook to free linear_solver_data

int *iWork#

integer work vector array (internal)

int iWorkSize#

size of integer work vector array

double *dWork#
int dWorkSize#
linalg_data_t *linalg_data#

data for the linear algebra

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 *triplet#

triplet format, aka coordinate

CSparseMatrix *half_triplet#

half triplet format for symmetric matrices

CSparseMatrix *csc#

csc matrix

CSparseMatrix *trans_csc#

transpose of a csc matrix (used by CSparse)

CSparseMatrix *csr#

csr matrix, only supported with mkl

CS_INT *diag_indx#

indices for the diagonal terms.

Very useful for the proximal perturbation

NSM_t origin#

original format of the matrix

NSM_linear_solver_params *linearSolverParams#

solver-specific parameters

NumericsDataVersion versions[5]#