|
programmer's documentation
|
#include <stdio.h>#include "cs_base.h"#include "cs_sdm.h"#include "cs_param.h"#include "cs_mesh_adjacencies.h"
Go to the source code of this file.
Data Structures | |
| struct | cs_sla_matrix_t |
| struct | cs_sla_hmatrix_t |
Macros | |
| #define | CS_SLA_MATRIX_SYM (1 << 0) /* 1: symmetric */ |
| #define | CS_SLA_MATRIX_SORTED (1 << 1) /* 2: sorted */ |
| #define | CS_SLA_MATRIX_SHARED (1 << 2) /* 4: share pattern */ |
Enumerations | |
| enum | cs_sla_matrix_type_t { CS_SLA_MAT_NONE, CS_SLA_MAT_DEC, CS_SLA_MAT_CSR, CS_SLA_MAT_MSR, CS_SLA_MAT_N_TYPES } |
Functions | |
| 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_adjacency_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_clean_zeros (cs_sla_matrix_t *m, double threshold, int verbosity) |
| Reset to 0 all entries below a given threshold Only available for CSR and MSR matrices with stride = 1. More... | |
| void | cs_sla_matrix_clean (int verbosity, double threshold, cs_sla_matrix_t *m) |
| Set to zero entries in a cs_sla_matrix_t structure if the ratio |a(i,j)| < eps * max|a(i,j)| is below a given threshold. 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_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... | |
| 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 where 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_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_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_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... | |
| cs_sla_hmatrix_t * | cs_sla_hmatrix_create (cs_lnum_t n_x, cs_lnum_t n_cells, bool bktrans, bool bk00sym, const cs_adjacency_t *x2x, const cs_adjacency_t *c2x) |
| Create a cs_sla_hmatrix_t structure This is a square matrix of size n_x+n_cells (stride = 1 up to now) More... | |
| cs_sla_hmatrix_t * | cs_sla_hmatrix_free (cs_sla_hmatrix_t *hm) |
| Free a cs_sla_hmatrix_t structure. More... | |
| void | cs_sla_hmatvec (const cs_sla_hmatrix_t *hm, const double vx[], const double vc[], double *iox[], double *ioc[], 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... | |
| #define CS_SLA_MATRIX_SHARED (1 << 2) /* 4: share pattern */ |
| #define CS_SLA_MATRIX_SORTED (1 << 1) /* 2: sorted */ |
| #define CS_SLA_MATRIX_SYM (1 << 0) /* 1: symmetric */ |
| enum cs_sla_matrix_type_t |
| 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_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_hmatrix_t* cs_sla_hmatrix_create | ( | cs_lnum_t | n_x, |
| cs_lnum_t | n_cells, | ||
| bool | bktrans, | ||
| bool | bk00sym, | ||
| const cs_adjacency_t * | x2x, | ||
| const cs_adjacency_t * | c2x | ||
| ) |
Create a cs_sla_hmatrix_t structure This is a square matrix of size n_x+n_cells (stride = 1 up to now)
| [in] | n_x | number of hybrid entities |
| [in] | n_cells | number of cells |
| [in] | bktrans | block (1,0) and (0,1) are transposed: true or false |
| [in] | bk00sym | block (0,0) is symmetric: true or false |
| [in] | x2x | pointer to cs_adjacency_t struc. |
| [in] | c2x | pointer to cs_adjacency_t struc. |
| cs_sla_hmatrix_t* cs_sla_hmatrix_free | ( | cs_sla_hmatrix_t * | hm | ) |
| void cs_sla_hmatvec | ( | const cs_sla_hmatrix_t * | hm, |
| const double | vx[], | ||
| const double | vc[], | ||
| double * | iox[], | ||
| double * | ioc[], | ||
| 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] | hm | pointer to a cs_sla_hmatrix_t structure |
| [in] | vx | pointer to an array of double (x-based values) |
| [in] | vc | pointer to an array of double (cell-based values) |
| [in,out] | iox | pointer to a pointer of double (x-based values) |
| [in,out] | ioc | pointer to a pointer of double (celle-based values) |
| [in] | reset | if true, first initialize inout to zero |
| 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 | ( | int | verbosity, |
| double | threshold, | ||
| cs_sla_matrix_t * | m | ||
| ) |
Set to zero entries in a cs_sla_matrix_t structure if the ratio |a(i,j)| < eps * max|a(i,j)| is below a given threshold. 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] | verbosity | indicate if one prints or not a message |
| [in] | threshold | value of the threshold |
| void cs_sla_matrix_clean_zeros | ( | cs_sla_matrix_t * | m, |
| double | threshold, | ||
| int | verbosity | ||
| ) |
Reset to 0 all entries below a given threshold Only available for CSR and MSR matrices with stride = 1.
| [in,out] | m | matrix to clean |
| [in] | threshold | threshold below one sets the value to zero |
| [in] | verbosity | indicate if one prints or not a message |
| 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 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 |
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: only pointer are copied other allocated |
| [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_adjacency_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_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 |
1.8.13