![]() |
programmer's documentation
|
#include "cs_defs.h"
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <bft_mem.h>
#include <bft_printf.h>
#include "cs_sort.h"
#include "cs_search.h"
#include "cs_sla.h"
Macros | |
#define | CS_SLA_MATRIX_DBG 0 |
Functions | |
static _spa_t * | _spa_init (size_t a_size, size_t l_size) |
Initialize a Sparse Accumulator (SPA) for MSR and CSR type. More... | |
static _spa_t * | _spa_free (_spa_t *spa) |
Free a Sparse Accumulator (SPA) for MSR and CSR type. More... | |
static _spa_dec_t * | _spa_dec_init (size_t a_size, size_t l_size) |
Initialize a Sparse Accumulator (SPA) for DEC type. More... | |
static _spa_dec_t * | _spa_dec_free (_spa_dec_t *spa) |
Free a Sparse Accumulator (SPA) for MSR and CSR type. More... | |
static void | _spa_add (_spa_t *spa, double value, cs_lnum_t pos, cs_lnum_t row_id) |
Add the contribution of a new entry. More... | |
static void | _spa_dec_add (_spa_dec_t *spa, short int value, cs_lnum_t pos, cs_lnum_t row_id) |
Add the contribution of a new entry. More... | |
static size_t | _spa_gather (_spa_t *spa, size_t idx, cs_lnum_t *col_id, double *val) |
Gather data from the current SPA state to update matrix structure Do not add zero entries. More... | |
static size_t | _spa_dec_gather (_spa_dec_t *spa, size_t idx, cs_lnum_t *col_id, short int *connect) |
Gather data from the current SPA state to update matrix structure Do not add zero entries. More... | |
static void | _estimate_sizes (const cs_sla_matrix_t *a, const cs_sla_matrix_t *b, size_t *nnz, size_t *stencil) |
Estimate roughly the number of nnz of the matrix c = a*b and the stencil of c. Size estimation is given by E. Cohen (1997) in Structure Prediction and Computation of Sparse Matrix Product. More... | |
static cs_sla_matrix_t * | _init_mat (const cs_sla_matrix_t *a, const cs_sla_matrix_t *b, cs_sla_matrix_type_t type, size_t guess_size) |
static void | _resize_mat (cs_sla_matrix_t *mat, size_t cur_size, size_t *max_size) |
static cs_sla_matrix_t * | _multiply_dec_matrices (const cs_sla_matrix_t *a, const cs_sla_matrix_t *b) |
Compute c = a*b for a and b in DEC storage. More... | |
static cs_sla_matrix_t * | _multiply_csr_matrices (const cs_sla_matrix_t *a, const cs_sla_matrix_t *b) |
Compute c = a*b for a and b in CSR storage. More... | |
static cs_sla_matrix_t * | _multiply_deccsr_matrices (const cs_sla_matrix_t *a, const cs_sla_matrix_t *b) |
Compute c = a*b for a in DEC storage and b in CSR storage. More... | |
static cs_sla_matrix_t * | _multiply_csrdec_matrices (const cs_sla_matrix_t *a, const cs_sla_matrix_t *b) |
Compute c = a*b for a in CSR storage and b in DEC storage. More... | |
static cs_sla_matrix_t * | _multiply_decmsr_matrices (const cs_sla_matrix_t *a, const cs_sla_matrix_t *b) |
Compute c = a*b for a in DEC storage and b in MSR storage. More... | |
static cs_sla_matrix_t * | _multiply_msrdec_matrices (const cs_sla_matrix_t *a, const cs_sla_matrix_t *b) |
Compute c = a*b for a in MSR storage and b in DEC storage. More... | |
static void | _decdec_AtDA (const cs_sla_matrix_t *At, const double D[], const cs_sla_matrix_t *A, cs_sla_matrix_t *C, int *w) |
Compute the product C = At * Diag * A where A and At are DEC matrices. More... | |
static void | _csrcsr_AtDA (const cs_sla_matrix_t *At, const double D[], const cs_sla_matrix_t *A, cs_sla_matrix_t *C, int *w) |
Compute the product C = At * Diag * A where A and At are CSR matrices. More... | |
static void | _pack_dec (cs_sla_matrix_t *final, const cs_sla_matrix_t *init, const cs_lnum_t *row_z2i_ids, const cs_lnum_t *col_i2z_ids) |
Fill a matrix resulting from an extraction of row/column for matrix in DEC format. More... | |
static void | _pack_csr (cs_sla_matrix_t *final, const cs_sla_matrix_t *init, const cs_lnum_t *row_z2i_ids, const cs_lnum_t *col_i2z_ids) |
Fill a matrix resulting from an extraction of row/column for matrix in CSR format. More... | |
static void | _pack_msr (cs_sla_matrix_t *final, const cs_sla_matrix_t *init, const cs_lnum_t *row_z2i_ids, const cs_lnum_t *col_i2z_ids, _Bool msr2csr) |
Fill a matrix resulting from an extraction of row/column for matrix in MSR format. More... | |
cs_sla_matrix_t * | cs_sla_matrix_create (cs_lnum_t n_rows, cs_lnum_t n_cols, int stride, cs_sla_matrix_type_t type, bool sym) |
Create a cs_sla_matrix_t structure. More... | |
cs_sla_matrix_t * | cs_sla_matrix_create_from_ref (const cs_sla_matrix_t *ref, cs_sla_matrix_type_t type, int stride) |
Create a cs_sla_matrix_t structure from an existing one. idx, didx and col_id are shared with ref. Initialize related buffers. More... | |
cs_sla_matrix_t * | cs_sla_matrix_create_msr_from_index (const cs_connect_index_t *connect_idx, bool is_symmetric, bool sorted_idx, int stride) |
Create a cs_sla_matrix_t structure with MSR type from an existing connectivity index. Be aware of removing the diagonal entry in the connectivity index before the call to this routine. More... | |
cs_sla_matrix_t * | cs_sla_matrix_copy (const cs_sla_matrix_t *a, bool shared) |
Create a new matrix structure from the copy of an existing one. More... | |
cs_sla_matrix_t * | cs_sla_matrix_transpose (const cs_sla_matrix_t *a) |
Transpose a cs_sla_matrix_t structure. More... | |
cs_sla_matrix_t * | cs_sla_matrix_free (cs_sla_matrix_t *m) |
Free a cs_sla_matrix_t structure. More... | |
void | cs_sla_matrix_rmzeros (cs_sla_matrix_t *m) |
Remove entries with zero values Only available for CSR and MSR matrices with stride = 1. More... | |
void | cs_sla_matrix_clean (cs_sla_matrix_t *m, double eps) |
Remove entries in a cs_sla_matrix_t structure below a given threshold. |a(i,j)| < eps * max|a(i,j)| i Be careful when using this function since one can loose the symmetry Only available for matrices with stride = 1. More... | |
size_t | cs_sla_matrix_get_nnz (const cs_sla_matrix_t *m) |
Retrieve the number of non-zeros (nnz) elements in a matrix. More... | |
void | cs_sla_matrix_diag_idx (cs_sla_matrix_t *m) |
Build diagonal index. More... | |
void | cs_sla_matrix_get_diag (const cs_sla_matrix_t *m, double *p_diag[]) |
Get the diagonal entries of a given matrix. More... | |
void | cs_sla_matrix_sort (cs_sla_matrix_t *m) |
Sort each row by increasing colomn number. More... | |
void | cs_sla_matrix_set_info (cs_sla_matrix_t *m) |
Compute general information related to a cs_sla_matrix_t structure and store it into a cs_sla_matrix_info_t structure. More... | |
void | cs_sla_matrix_msr2csr (cs_sla_matrix_t *a) |
Change matrix representation from MSR to CSR. More... | |
void | cs_sla_matrix_csr2msr (cs_sla_matrix_t *a) |
Change matrix representation from CSR to MSR. More... | |
void | cs_sla_matrix_share2own (cs_sla_matrix_t *a) |
Allocate its own pattern if shared. More... | |
void | cs_sla_assemble_msr_sym (const cs_locmat_t *loc, cs_sla_matrix_t *ass, bool only_diag) |
Assemble a MSR matrix from local contributions –> We assume that the local matrices are symmetric –> We assume that the assembled matrix has its columns sorted. More... | |
void | cs_sla_assemble_msr (const cs_locmat_t *loc, cs_sla_matrix_t *ass) |
Assemble a MSR matrix from local contributions –> We assume that the assembled matrix has its columns sorted. More... | |
cs_sla_matrix_t * | cs_sla_matrix_pack (cs_lnum_t n_final_rows, cs_lnum_t n_final_cols, const cs_sla_matrix_t *init, const cs_lnum_t *row_z2i_ids, const cs_lnum_t *col_i2z_ids, _Bool keep_sym) |
Build a new matrix resulting from the extraction of some listed rows and columns. The output is a new matrix packed (or zipped) w.r.t the initial matrix. More... | |
cs_sla_matrix_t * | cs_sla_matrix_add (double alpha, const cs_sla_matrix_t *a, double beta, const cs_sla_matrix_t *b) |
Add two sparse matrices a and b. c = alpha*a + beta*b. More... | |
void | cs_sla_matvec (const cs_sla_matrix_t *m, const double v[], double *inout[], bool reset) |
Compute a matrix vector product. If inout is not allocated, allocation is done inside this function If reset is set to true, initialization inout to 0. More... | |
void | cs_sla_amxby (double alpha, const cs_sla_matrix_t *m, const double x[], double beta, const double y[], double *inout[]) |
Compute an array resulting from alpha * M(x) + beta * y If inout is not allocated, allocation is done inside this function. More... | |
cs_sla_matrix_t * | cs_sla_matrix_multiply (const cs_sla_matrix_t *a, const cs_sla_matrix_t *b) |
Main subroutine to multiply two sparse matrices a and b. c= a*b. More... | |
cs_sla_matrix_t * | cs_sla_multiply_AtDA (const cs_sla_matrix_t *At, const double D[], const cs_sla_matrix_t *A, cs_lnum_t *w) |
Compute the product C = At * Diag * A. More... | |
cs_sla_matrix_t * | cs_sla_matrix_combine (double alpha, const cs_sla_matrix_t *a, double beta, const cs_sla_matrix_t *bt, const cs_sla_matrix_t *b) |
Specific matrix multiplication. Compute Bt * beta * B + alpha * A alpha and beta are scalar. More... | |
void | cs_sla_matvec_block2 (const cs_sla_matrix_t *A, const cs_sla_matrix_t *B, const cs_sla_matrix_t *C, const cs_sla_matrix_t *D, const double X[], const double Y[], double *F[], double *G[], _Bool reset) |
Matrix block 2x2 multiply by a vector. More... | |
void | cs_sla_bread (const char *name, cs_sla_matrix_t **p_mat, double *p_rhs[], double *p_sol[]) |
Read from a binary file a matrix in CSR format, its righ hand side and the solution. Matrix must have a stride equal to 1. More... | |
void | cs_sla_bwrite (const char *name, const cs_sla_matrix_t *m, const double *rhs, const double *sol) |
Write in binary format a matrix in CSR format, its righ hand side and the solution. More... | |
void | cs_sla_matrix_summary (const char *name, FILE *f, cs_sla_matrix_t *m) |
Synthesis of a cs_sla_matrix_t structure. More... | |
void | cs_sla_matrix_dump (const char *name, FILE *f, const cs_sla_matrix_t *m) |
Dump a cs_sla_matrix_t structure. More... | |
void | cs_sla_system_dump (const char *name, FILE *f, const cs_sla_matrix_t *m, const double *rhs) |
Dump a cs_sla_matrix_t structure and its related right-hand side. More... | |
Variables | |
static const char | _sla_err_stride [] |
static const char | _sla_matrix_type [CS_SLA_MAT_N_TYPES][CS_CDO_LEN_NAME] |
#define CS_SLA_MATRIX_DBG 0 |
|
static |
Compute the product C = At * Diag * A where A and At are CSR matrices.
[in] | At | pointer to a cs_sla_matrix_t struct. (CSR type) |
[in] | D | array standing for a diagonal operator |
[in] | A | pointer to a cs_sla_matrix_t struct. (CSR type) |
[in,out] | C | pointer to a cs_sla_matrix_t storing the result |
[in,out] | w | work buffer |
|
static |
Compute the product C = At * Diag * A where A and At are DEC matrices.
[in] | At | pointer to a cs_sla_matrix_t struct. (DEC type) |
[in] | D | array standing for a diagonal operator |
[in] | A | pointer to a cs_sla_matrix_t struct. (DEC type) |
[in,out] | C | pointer to a cs_sla_matrix_t storing the result |
[in,out] | w | work buffer |
|
static |
Estimate roughly the number of nnz of the matrix c = a*b and the stencil of c. Size estimation is given by E. Cohen (1997) in Structure Prediction and Computation of Sparse Matrix Product.
[in] | a | pointer to the matrix struct. a |
[in] | b | pointer to the matrix struct. b |
[in,out] | nnz | size_t element |
[in,out] | stencil | size_t element |
|
static |
|
static |
Compute c = a*b for a and b in CSR storage.
[in] | a | pointer to the matrix struct. a |
[in] | b | pointer to the matrix struct. b |
|
static |
Compute c = a*b for a in CSR storage and b in DEC storage.
[in] | a | pointer to the matrix struct. a |
[in] | b | pointer to the matrix struct. b |
|
static |
Compute c = a*b for a and b in DEC storage.
[in] | a | pointer to the matrix struct. a |
[in] | b | pointer to the matrix struct. b |
|
static |
Compute c = a*b for a in DEC storage and b in CSR storage.
[in] | a | pointer to the matrix struct. a |
[in] | b | pointer to the matrix struct. b |
|
static |
Compute c = a*b for a in DEC storage and b in MSR storage.
[in] | a | pointer to the matrix struct. a |
[in] | b | pointer to the matrix struct. b |
|
static |
Compute c = a*b for a in MSR storage and b in DEC storage.
[in] | a | pointer to the matrix struct. a |
[in] | b | pointer to the matrix struct. b |
|
static |
Fill a matrix resulting from an extraction of row/column for matrix in CSR format.
[in,out] | final | pointer to the block matrix struct. |
[in] | init | init matrix to work with |
[in] | row_z2i_ids | zipped -> init numbering for rows |
[in] | col_i2z_ids | init -> zipped numbering for columns |
|
static |
Fill a matrix resulting from an extraction of row/column for matrix in DEC format.
[in,out] | final | pointer to the final matrix struct. |
[in] | init | init matrix to work with |
[in] | row_z2i_ids | zipped -> init numbering for rows |
[in] | col_i2z_ids | init -> zipped numbering for columns |
|
static |
Fill a matrix resulting from an extraction of row/column for matrix in MSR format.
[in,out] | final | pointer to the block matrix struct. |
[in] | init | init matrix to work with |
[in] | row_z2i_ids | zipped -> init numbering for rows |
[in] | col_i2z_ids | init -> zipped numbering for columns |
[in] | msr2csr | change matrix type |
|
static |
Add the contribution of a new entry.
[in,out] | spa | pointer to the SPA struct. to update |
[in] | value | value to add |
[in] | pos | position related to this value |
[in] | row_id | current row |
|
inlinestatic |
Add the contribution of a new entry.
[in,out] | spa | pointer to the SPA struct. to update |
[in] | value | value to add |
[in] | pos | position related to this value |
[in] | row_id | current row |
|
static |
Free a Sparse Accumulator (SPA) for MSR and CSR type.
[in,out] | spa | pointer to a SPA struct. to free |
|
static |
Gather data from the current SPA state to update matrix structure Do not add zero entries.
[in] | spa | pointer to the SPA struct. |
[in] | idx | current index position |
[in,out] | col_id | pointer to matrix->col_id array |
[in,out] | connect | pointer to matrix->sgn array |
|
static |
Initialize a Sparse Accumulator (SPA) for DEC type.
[in] | a_size | size of tag and connect arrays |
[in] | l_size | size of lst |
|
static |
Free a Sparse Accumulator (SPA) for MSR and CSR type.
[in,out] | spa | pointer to a SPA struct. to free |
|
static |
Gather data from the current SPA state to update matrix structure Do not add zero entries.
[in] | spa | pointer to the SPA struct. |
[in] | idx | current index position |
[in,out] | col_id | pointer to matrix->col_id array |
[in,out] | val | pointer to matrix->val array |
|
static |
Initialize a Sparse Accumulator (SPA) for MSR and CSR type.
[in] | a_size | size of tag and val arrays |
[in] | l_size | size of lst |
void cs_sla_amxby | ( | double | alpha, |
const cs_sla_matrix_t * | m, | ||
const double | x[], | ||
double | beta, | ||
const double | y[], | ||
double * | inout[] | ||
) |
Compute an array resulting from alpha * M(x) + beta * y If inout is not allocated, allocation is done inside this function.
[in] | alpha | multiplicative coefficient |
[in] | m | pointer to a cs_sla_matrix_t structure |
[in] | x | pointer to an array of double |
[in] | beta | multiplicative coefficient |
[in] | y | pointer to an array of double |
[in,out] | inout | pointer to a pointer of double |
void cs_sla_assemble_msr | ( | const cs_locmat_t * | loc, |
cs_sla_matrix_t * | ass | ||
) |
Assemble a MSR matrix from local contributions –> We assume that the assembled matrix has its columns sorted.
[in] | loc | pointer to a local matrix |
[in,out] | ass | pointer to a cs_sla_matrix_t struct. collecting data |
void cs_sla_assemble_msr_sym | ( | const cs_locmat_t * | loc, |
cs_sla_matrix_t * | ass, | ||
bool | only_diag | ||
) |
Assemble a MSR matrix from local contributions –> We assume that the local matrices are symmetric –> We assume that the assembled matrix has its columns sorted.
[in] | loc | pointer to a local matrix |
[in,out] | ass | pointer to a cs_sla_matrix_t struct. |
[in] | only_diag | true if assembly is only for diagonal terms |
void cs_sla_bread | ( | const char * | name, |
cs_sla_matrix_t ** | p_mat, | ||
double * | p_rhs[], | ||
double * | p_sol[] | ||
) |
Read from a binary file a matrix in CSR format, its righ hand side and the solution. Matrix must have a stride equal to 1.
[in] | name | name of the output file |
[in,out] | p_mat | system to solve |
[in,out] | p_rhs | right hand side |
[in,out] | p_sol | solution |
void cs_sla_bwrite | ( | const char * | name, |
const cs_sla_matrix_t * | m, | ||
const double * | rhs, | ||
const double * | sol | ||
) |
Write in binary format a matrix in CSR format, its righ hand side and the solution.
[in] | name | name of the output file |
[in] | m | system to solve |
[in] | rhs | right hand side |
[in] | sol | solution |
cs_sla_matrix_t* cs_sla_matrix_add | ( | double | alpha, |
const cs_sla_matrix_t * | a, | ||
double | beta, | ||
const cs_sla_matrix_t * | b | ||
) |
Add two sparse matrices a and b. c = alpha*a + beta*b.
[in] | alpha | first coef. |
[in] | a | first matrix to add |
[in] | beta | second coef. |
[in] | b | second matrix to add |
void cs_sla_matrix_clean | ( | cs_sla_matrix_t * | m, |
double | eps | ||
) |
Remove entries in a cs_sla_matrix_t structure below a given threshold. |a(i,j)| < eps * max|a(i,j)| i Be careful when using this function since one can loose the symmetry Only available for matrices with stride = 1.
Remove entries in a cs_sla_matrix_t structure below a given threshold. |a(i,j)| < eps * max|a(i,j)| Be careful when using this function since one can loose the symmetry Only available for matrices with stride = 1.
[in,out] | m | matrix to clean |
[in] | eps | value of the threshold |
cs_sla_matrix_t* cs_sla_matrix_combine | ( | double | alpha, |
const cs_sla_matrix_t * | a, | ||
double | beta, | ||
const cs_sla_matrix_t * | bt, | ||
const cs_sla_matrix_t * | b | ||
) |
Specific matrix multiplication. Compute Bt * beta * B + alpha * A alpha and beta are scalar.
Specific matrix multiplication. Compute Bt * beta * B + alpha * A where alpha and beta are scalar.
[in] | alpha | real coefficient |
[in] | a | square sym. matrix |
[in] | beta | real coefficient |
[in] | b | matrix (CSR or DEC) |
[in] | bt | adjoint matrix of b |
cs_sla_matrix_t* cs_sla_matrix_copy | ( | const cs_sla_matrix_t * | a, |
bool | shared | ||
) |
Create a new matrix structure from the copy of an existing one.
[in] | a | matrix to copy |
[in] | shared | true: index information (idx, col_id) is shared |
cs_sla_matrix_t* cs_sla_matrix_create | ( | cs_lnum_t | n_rows, |
cs_lnum_t | n_cols, | ||
int | stride, | ||
cs_sla_matrix_type_t | type, | ||
bool | sym | ||
) |
Create a cs_sla_matrix_t structure.
[in] | n_rows | number of rows |
[in] | n_cols | number of columns |
[in] | stride | number of values related to each entry |
[in] | type | kind of matrix |
[in] | sym | true or false |
cs_sla_matrix_t* cs_sla_matrix_create_from_ref | ( | const cs_sla_matrix_t * | ref, |
cs_sla_matrix_type_t | type, | ||
int | stride | ||
) |
Create a cs_sla_matrix_t structure from an existing one. idx, didx and col_id are shared with ref. Initialize related buffers.
[in] | ref | pointer to a reference matrix with the same pattern |
[in] | type | type of the matrix to create |
[in] | stride | number of values for each entry |
cs_sla_matrix_t* cs_sla_matrix_create_msr_from_index | ( | const cs_connect_index_t * | connect_idx, |
bool | is_symmetric, | ||
bool | sorted_idx, | ||
int | stride | ||
) |
Create a cs_sla_matrix_t structure with MSR type from an existing connectivity index. Be aware of removing the diagonal entry in the connectivity index before the call to this routine.
[in] | connect_idx | pointer to a connectivity index |
[in] | is_symmetric | true or false |
[in] | sorted_idx | true if the connectivity index is sorted |
[in] | stride | number of values for each entry |
void cs_sla_matrix_csr2msr | ( | cs_sla_matrix_t * | a | ) |
Change matrix representation from CSR to MSR.
[in,out] | a | matrix to transform |
void cs_sla_matrix_diag_idx | ( | cs_sla_matrix_t * | m | ) |
Build diagonal index.
[in,out] | m | matrix to work with |
void cs_sla_matrix_dump | ( | const char * | name, |
FILE * | f, | ||
const cs_sla_matrix_t * | m | ||
) |
Dump a cs_sla_matrix_t structure.
[in] | name | either name of the file if f is NULL or description |
[in] | f | pointer to a FILE struct. |
[in] | m | matrix to dump |
cs_sla_matrix_t* cs_sla_matrix_free | ( | cs_sla_matrix_t * | m | ) |
void cs_sla_matrix_get_diag | ( | const cs_sla_matrix_t * | m, |
double * | p_diag[] | ||
) |
Get the diagonal entries of a given matrix.
[in] | m | matrix to work with |
[in,out] | p_diag | pointer to diag array to define (allocated if NULL) |
size_t cs_sla_matrix_get_nnz | ( | const cs_sla_matrix_t * | m | ) |
Retrieve the number of non-zeros (nnz) elements in a matrix.
[in] | m | matrix |
void cs_sla_matrix_msr2csr | ( | cs_sla_matrix_t * | a | ) |
Change matrix representation from MSR to CSR.
[in,out] | a | matrix to transform |
cs_sla_matrix_t* cs_sla_matrix_multiply | ( | const cs_sla_matrix_t * | a, |
const cs_sla_matrix_t * | b | ||
) |
Main subroutine to multiply two sparse matrices a and b. c= a*b.
[in] | a | first matrix to multiply |
[in] | b | second matrix to multiply |
cs_sla_matrix_t* cs_sla_matrix_pack | ( | cs_lnum_t | n_final_rows, |
cs_lnum_t | n_final_cols, | ||
const cs_sla_matrix_t * | init, | ||
const cs_lnum_t * | row_z2i_ids, | ||
const cs_lnum_t * | col_i2z_ids, | ||
_Bool | keep_sym | ||
) |
Build a new matrix resulting from the extraction of some listed rows and columns. The output is a new matrix packed (or zipped) w.r.t the initial matrix.
[in] | n_final_rows | number of rows to extract |
[in] | n_final_cols | number of columns to extract |
[in] | init | init matrix to work with |
[in] | row_z2i_ids | zipped -> initial ids for rows |
[in] | col_i2z_ids | initial-> zipped ids for columns (-1 ==> remove) |
[in] | keep_sym | true or false |
void cs_sla_matrix_rmzeros | ( | cs_sla_matrix_t * | m | ) |
Remove entries with zero values Only available for CSR and MSR matrices with stride = 1.
[in,out] | m | matrix to clean |
void cs_sla_matrix_set_info | ( | cs_sla_matrix_t * | m | ) |
Compute general information related to a cs_sla_matrix_t structure and store it into a cs_sla_matrix_info_t structure.
[in,out] | m | matrix to analyse |
void cs_sla_matrix_share2own | ( | cs_sla_matrix_t * | a | ) |
Allocate its own pattern if shared.
[in,out] | a | matrix to transform |
void cs_sla_matrix_sort | ( | cs_sla_matrix_t * | m | ) |
Sort each row by increasing colomn number.
[in] | m | matrix to sort |
void cs_sla_matrix_summary | ( | const char * | name, |
FILE * | f, | ||
cs_sla_matrix_t * | m | ||
) |
Synthesis of a cs_sla_matrix_t structure.
[in] | name | either name of the file if f is NULL or description |
[in] | f | pointer to a FILE struct. |
[in,out] | m | matrix to dump (info can be computed inside) |
cs_sla_matrix_t* cs_sla_matrix_transpose | ( | const cs_sla_matrix_t * | a | ) |
Transpose a cs_sla_matrix_t structure.
[in] | a | matrix to transpose |
void cs_sla_matvec | ( | const cs_sla_matrix_t * | m, |
const double | v[], | ||
double * | inout[], | ||
bool | reset | ||
) |
Compute a matrix vector product. If inout is not allocated, allocation is done inside this function If reset is set to true, initialization inout to 0.
[in] | m | pointer to a cs_sla_matrix_t structure |
[in] | v | pointer to an array of double |
[in,out] | inout | pointer to a pointer of double |
[in] | reset | if true, first initialize inout to zero |
void cs_sla_matvec_block2 | ( | const cs_sla_matrix_t * | A, |
const cs_sla_matrix_t * | B, | ||
const cs_sla_matrix_t * | C, | ||
const cs_sla_matrix_t * | D, | ||
const double | X[], | ||
const double | Y[], | ||
double * | F[], | ||
double * | G[], | ||
_Bool | reset | ||
) |
Matrix block 2x2 multiply by a vector.
| A B | |X| = |F|= |AX + BY| | C D | |Y| |G| |CX + DY|
[in] | A | pointer to a cs_sla_matrix_t block (1,1) |
[in] | B | pointer to a cs_sla_matrix_t block (1,2) |
[in] | C | pointer to a cs_sla_matrix_t block (2,1) |
[in] | D | pointer to a cs_sla_matrix_t block (2,2) |
[in] | X | upper vector |
[in] | Y | lower vector |
[in,out] | F | upper result |
[in,out] | G | lower result |
[in] | reset | reset before computation (true/false) |
cs_sla_matrix_t* cs_sla_multiply_AtDA | ( | const cs_sla_matrix_t * | At, |
const double | D[], | ||
const cs_sla_matrix_t * | A, | ||
cs_lnum_t * | w | ||
) |
Compute the product C = At * Diag * A.
[in] | At | pointer to a cs_sla_matrix_t struct. (DEC type) |
[in] | D | array standing for a diagonal operator |
[in] | A | pointer to a cs_sla_matrix_t struct. (DEC type) |
[in,out] | w | work buffer |
void cs_sla_system_dump | ( | const char * | name, |
FILE * | f, | ||
const cs_sla_matrix_t * | m, | ||
const double * | rhs | ||
) |
Dump a cs_sla_matrix_t structure and its related right-hand side.
[in] | name | either name of the file if f is NULL or description |
[in] | f | pointer to a FILE struct. |
[in] | m | matrix to dump |
[in] | rhs | right-hand side to dump |
|
static |
|
static |