|
programmer's documentation
|
#include <stdio.h>#include "cs_base.h"#include "cs_cdo.h"#include "cs_cdo_toolbox.h"#include "cs_param.h"
Go to the source code of this file.
Data Structures | |
| struct | cs_sla_matrix_info_t |
| struct | cs_sla_matrix_t |
| struct | cs_sla_sumup_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 | |
| 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_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... | |
| 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... | |
| cs_sla_matrix_t * | cs_sla_block2mat (cs_sla_matrix_t *A, const cs_sla_matrix_t *B, const cs_sla_matrix_t *C, const cs_sla_matrix_t *D, bool sym) |
| void | cs_sla_matvec (const cs_sla_matrix_t *m, const double v[], double *inout[], bool reset) |
| void | cs_sla_amxby (double alpha, const cs_sla_matrix_t *m, const double x[], double beta, const double y[], double *inout[]) |
| 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... | |
| 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... | |
| 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_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... | |
| cs_sla_matrix_t * | cs_sla_multiply_AtDA (const cs_sla_matrix_t *At, const double D[], const cs_sla_matrix_t *A, int *w) |
| Compute the product C = At * Diag * A. More... | |
| int | cs_sla_get_mat_spectral_radius (const cs_sla_matrix_t *matrix, int iter_max, double epsilon, double *lambda) |
| double | cs_sla_get_matrix_norm (const cs_sla_matrix_t *m) |
| cs_sla_matrix_t * | cs_sla_matrix_create (int n_rows, int 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_pattern (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. 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 *mat) |
| 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 (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)|. 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... | |
| cs_sla_matrix_info_t | cs_sla_matrix_analyse (const cs_sla_matrix_t *m) |
| Compute general information related to a cs_sla_matrix_t structure. More... | |
| void | cs_sla_matrix_resume (const char *name, FILE *f, const 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... | |
| void | cs_sla_assemble_msr (const cs_toolbox_locmat_t *loc, cs_sla_matrix_t *ass) |
| 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... | |
| #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[] | ||
| ) |
| void cs_sla_assemble_msr | ( | const cs_toolbox_locmat_t * | loc, |
| cs_sla_matrix_t * | ass | ||
| ) |
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. collecting data |
| cs_sla_matrix_t* cs_sla_block2mat | ( | cs_sla_matrix_t * | A, |
| const cs_sla_matrix_t * | B, | ||
| const cs_sla_matrix_t * | C, | ||
| const cs_sla_matrix_t * | D, | ||
| bool | sym | ||
| ) |
| 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] | A | system to solve |
| [in] | rhs | right hand side |
| [in] | x | solution |
| int cs_sla_get_mat_spectral_radius | ( | const cs_sla_matrix_t * | matrix, |
| int | iter_max, | ||
| double | epsilon, | ||
| double * | lambda | ||
| ) |
| double cs_sla_get_matrix_norm | ( | const cs_sla_matrix_t * | m | ) |
| 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 |
| cs_sla_matrix_info_t cs_sla_matrix_analyse | ( | const cs_sla_matrix_t * | m | ) |
Compute general information related to a cs_sla_matrix_t structure.
| [in] | m | matrix to analyse |
| 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)|.
| [in,out] | mat | matrix to clean |
| [in] | eps | value of the threshold |
Remove entries in a cs_sla_matrix_t structure below a given threshold. |a(i,j)| < eps * max|a(i,j)|.
| [in,out] | mat | 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.
| [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 |
| [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 |
| cs_sla_matrix_t* cs_sla_matrix_create | ( | int | n_rows, |
| int | 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_pattern | ( | 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.
| [in] | ref | pointer to a reference matrix with the same pattern |
| [in] | type | type of the matrix to create |
| [in] | stride | number of values associated to each entry |
| [in] | ref | pointer to a reference matrix with the same pattern |
| [in] | type | type of the matrix to create |
| [in] | stride | true or false |
| 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 |
| [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] | dump_level | level of information displayed |
| 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] | mat | 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_resume | ( | const char * | name, |
| FILE * | f, | ||
| const 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] | m | matrix to dump |
| 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] | mat | matrix to sort |
| cs_sla_matrix_t* cs_sla_matrix_transpose | ( | const cs_sla_matrix_t * | a | ) |
Transpose a cs_sla_matrix_t structure.
| [in] | mat | matrix to transpose |
| void cs_sla_matvec | ( | const cs_sla_matrix_t * | m, |
| const double | v[], | ||
| double * | inout[], | ||
| bool | reset | ||
| ) |
| 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, | ||
| int * | 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.7