#include "Matrix/LinkMatrixSparse.hpp"
#include "Matrix/NF_Triplet.hpp"
#include "Basic/AStringable.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/VectorHelper.hpp"
#include "Basic/File.hpp"
#include "Basic/String.hpp"
#include "Basic/OptDbg.hpp"
#include "Basic/Memory.hpp"
#include "Core/Keypair.hpp"
#include "geoslib_old_f.h"
#include <set>
#include "csparse_f.h"
Macros | |
#define | MAX_NEIGH 100 |
#define | XCR(ilevel, i) (xcr[(ilevel) * ncur + (i)]) |
#define | RHS(ilevel, i) (rhs[(ilevel) * ncur + (i)]) |
#define | MAT(i, j) (mat[(i) * n + (j)]) |
#define | DEBUG 0 |
Functions | |
static int | _cs_update_nonzero_value (int row, int col, double value) |
void | cs_set_status_update_nonzero_value (int status) |
int | cs_get_status_update_nonzero_value () |
cs * | cs_spalloc2 (int m, int n, int nzmax, int values, int triplet) |
cs * | cs_spfree2 (cs *A) |
TODO : cs_*2 functions to be removed (encapsulation) More... | |
css * | cs_sfree2 (css *S) |
csn * | cs_nfree2 (csn *N) |
int | cs_entry2 (cs *T, int i, int j, double x) |
cs * | cs_triplet2 (const cs *T) |
cs * | cs_transpose2 (const cs *A, int values) |
cs * | cs_multiply2 (const cs *A, const cs *B) |
int | cs_print2 (const cs *A, int brief) |
void | cs_force_dimension (cs *T, int nrow, int ncol) |
cs * | cs_diag (VectorDouble diag, double tol) |
cs * | cs_prod_norm_diagonal (int mode, const cs *B, const VectorDouble &diag) |
MatrixSparse * | cs_arrays_to_sparse (int n, int nrow, int ncol, const double *rows, const double *cols, const double *vals) |
MatrixSparse * | cs_vectors_to_sparse (int nrow, int ncol, const VectorDouble &rows, const VectorDouble &cols, const VectorDouble &values) |
cs * | cs_invert (const cs *A, int order, double epsilon) |
static void | st_selection_update (int ncur, double *sel, const int *indCo) |
int | _cs_findColor (const cs *Q, int imesh, int ncolor, VectorInt &colors, VectorInt &temp) |
int | qchol_cholesky (int verbose, QChol *QC) |
static void | st_path_define (cs_MGS *mgs, int nlevels, int path_type) |
static void | st_multigrid_set_default_params (cs_MGS *mgs) |
void | cs_multigrid_params (cs_MGS *mgs, int flag_cg, int type_coarse, int ngc, int nmg, int ngs, double tolcg, double tolnmg) |
static cs_MG * | st_monogrid_manage (int mode, cs_MG *mg) |
static void | st_path_print (int nlevels, int npath, int *path) |
cs_MGS * | cs_multigrid_manage (cs_MGS *mgs, int mode, int nlevels, int path_type) |
static void | st_mg_print (cs_MGS *mgs, int rank) |
void | cs_multigrid_print (cs_MGS *mgs) |
int | cs_multigrid_get_nlevels (cs_MGS *mgs) |
static void | st_multigrid_scale (cs_MGS *mgs, int mode, double *z, double *b) |
static void | st_multigrid_ascent (cs_MGS *mgs, int level, int flag_init, int flag_scale, double *zin, double *zout, double *work) |
void | cs_multigrid_coarse2fine (cs_MGS *mgs, double *z, double *work) |
static void | st_multigrid_descent (cs_MGS *mgs, int level, double *zin, const double *rhsin, double *rhsout, double *work) |
int | cs_multigrid_setup (cs_MGS *mgs, QChol *qctt, int flag_sel, int verbose, double **sel_arg) |
int | cs_scale (const cs *A) |
void | cs_chol_invert (QChol *qctt, double *xcr, double *rhs, double *work) |
void | cs_chol_simulate (QChol *qctt, double *simu, double *work) |
static void | st_relaxation (cs_MGS *mgs, int level, int mode, double *xcr, const double *rhs, double *work) |
static int | st_multigrid_kriging_prec (cs_MGS *mgs, int verbose, double *x, double *b, double *work) |
static int | st_multigrid_kriging_cg (cs_MGS *mgs, int verbose, double *x, double *b, double *work) |
int | cs_multigrid_process (cs_MGS *mgs, QChol *qctt, int verbose, double *x0, double *b, double *work) |
NF_Triplet | csToTriplet (const cs *A, int shiftRow, int shiftCol, double tol) |
String | toStringDim (const String &title, const cs *A) |
String | toStringRange (const String &title, const cs *C) |
bool | cs_isSymmetric (const cs *A, bool verbose, bool detail) |
bool | cs_isDiagonalDominant (cs *A, bool verbose, bool detail) |
bool | cs_isDefinitePositive (cs *A, bool verbose) |
cs * | cs_extract_submatrix (cs *C, int row_from, int row_length, int col_from, int col_length) |
int | cs_get_nrow (const cs *A) |
int | cs_get_ncol (const cs *A) |
int | cs_get_ncell (const cs *A) |
void | cs_print_dim (const char *title, const cs *A) |
void | cs_print_range (const char *title, const cs *C) |
cs * | cs_eye (int number, double value) |
cs * | cs_extract_diag (const cs *C, int oper_choice) |
double * | csd_extract_diag (const cs *C, int oper_choice) |
VectorDouble | csd_extract_diag_VD (const cs *C, int oper_choice) |
void | cs_diag_suppress (cs *C) |
int | cs_sort_i (cs *C) |
void | cs_rowcol (const cs *A, int *nrows, int *ncols, int *count, double *percent) |
void | cs_print_nice (const char *title, const cs *A, int maxrow, int maxcol) |
void | cs_print_only (const char *title, const cs *A, int nlimit) |
void | cs_print_short (const char *title, const cs *L, int nmax) |
cs * | cs_eye_tab (int number, double *values) |
cs * | cs_multiply_and_release (cs *b1, const cs *b2, int flag_release) |
cs * | cs_add_and_release (cs *b1, const cs *b2, double alpha, double beta, int flag_release) |
cs * | cs_duplicate (const cs *b1) |
cs * | cs_prod_norm_and_release (cs *b1, cs *lambda, int flag_release) |
double | cs_maxsumabscol (const cs *A) |
double * | cs_col_sumrow (const cs *A, int *ncol, int *nrow) |
void | cs_vector_Mx (const cs *A, int nout, const double *x, double *y) |
void | cs_vector_addToDest_Mx (const cs *A, int nout, const double *x, double *y) |
void | cs_vector_tMx (const cs *A, int nout, const double *x, double *y) |
void | cs_vector_addToDest_tMx (const cs *A, int nout, const double *x, double *y) |
void | cs_vector_xM (const cs *A, int nout, const double *x, double *y) |
void | cs_vector_xtM (const cs *A, int nout, const double *x, double *y) |
cs * | cs_normalize_by_diag_and_release (cs *Q, int flag_release) |
cs * | cs_matvecR (const cs *A, const double *x, int oper_choice) |
cs * | cs_matvecL (const cs *A, const double *x, int oper_choice) |
cs * | cs_matvecnorm (const cs *A, const double *x, int oper_choice) |
void | cs_matvecnorm_inplace (cs *A, const double *x, int oper_choice) |
static void | st_get_FiCo (cs *L, cs *Lt, int *lambda, int *indUd, int *indFi, int *indCo) |
static int | st_update_neigh (int *n_arg, int indloc, int *n_tab, int *r_tab) |
static int | st_coarse_type0 (const cs *Q, int *indUd, int *indFi, int *indCo, cs **Lret, cs **Ltret) |
static int | st_coarse_typen (cs *, cs *Lt, int type, int *indUd, int *indFi, int *indCo) |
int | cs_coarsening (const cs *Q, int type, int **indCo_ret, cs **L_ret) |
cs * | cs_interpolate (const cs *AA, const cs *Lt, const int *Co) |
cs * | cs_prod_norm (int mode, const cs *A, const cs *B) |
cs * | cs_prod_norm_single (int mode, const cs *B) |
cs * | cs_triangle (cs *A, int flag_upper, int flag_diag) |
int | cs_lsolve_lowtri (const cs *L, const double *x, double *y) |
int | cs_lsolve_uptri (const cs *L, const double *x, double *y) |
void | cs_mulvec_uptri (const cs *A, int nout, const double *x, double *y, int flag_diag) |
void | cs_mulvec_lowtri (const cs *A, int nout, const double *x, double *y, int flag_diag) |
cs * | cs_compress (cs *A) |
void | cs_print_file (const char *radix, int rank, const cs *A) |
bool | cs_exist (const cs *A, int row, int col) |
double | cs_get_value (const cs *A, int row, int col) |
void | cs_set_value (const cs *A, int row, int col, double value) |
void | cs_add_value (const cs *A, int row, int col, double value) |
void | cs_add_cste (cs *A, double value) |
void | cs_set_cste (const cs *A, double value) |
double * | cs_toArray (const cs *A) |
int | cs_nnz (const cs *A) |
cs * | cs_strip (cs *A, double eps, int hypothesis, bool verbose) |
cs * | cs_glue (const cs *A1, const cs *A2, bool shiftRow, bool shiftCol) |
void | cs_gibbs (const cs *A, int iech, const VectorDouble &zcur, double *yk, double *sk) |
Variables | |
static int | flagUpdateNonzero = 1 |
#define DEBUG 0 |
#define MAT | ( | i, | |
j | |||
) | (mat[(i) * n + (j)]) |
#define MAX_NEIGH 100 |
#define RHS | ( | ilevel, | |
i | |||
) | (rhs[(ilevel) * ncur + (i)]) |
#define XCR | ( | ilevel, | |
i | |||
) | (xcr[(ilevel) * ncur + (i)]) |
|
static |
cs* cs_add_and_release | ( | cs * | b1, |
const cs * | b2, | ||
double | alpha, | ||
double | beta, | ||
int | flag_release | ||
) |
void cs_add_cste | ( | cs * | A, |
double | value | ||
) |
void cs_add_value | ( | const cs * | A, |
int | row, | ||
int | col, | ||
double | value | ||
) |
MatrixSparse* cs_arrays_to_sparse | ( | int | n, |
int | nrow, | ||
int | ncol, | ||
const double * | rows, | ||
const double * | cols, | ||
const double * | vals | ||
) |
void cs_chol_invert | ( | QChol * | qctt, |
double * | xcr, | ||
double * | rhs, | ||
double * | work | ||
) |
Inversion using Cholesky
[in] | qctt | Qchol structure |
[in,out] | xcr | Current vector |
[in] | rhs | Current R.H.S. vector |
[out] | work | Working array |
void cs_chol_simulate | ( | QChol * | qctt, |
double * | simu, | ||
double * | work | ||
) |
Simulate using Cholesky
[in] | qctt | Qchol structure |
[out] | simu | Simulated array |
[out] | work | Working array |
int cs_coarsening | ( | const cs * | Q, |
int | type, | ||
int ** | indCo_ret, | ||
cs ** | L_ret | ||
) |
double* cs_col_sumrow | ( | const cs * | A, |
int * | ncol, | ||
int * | nrow | ||
) |
cs* cs_compress | ( | cs * | A | ) |
cs* cs_diag | ( | VectorDouble | diag, |
double | tol | ||
) |
void cs_diag_suppress | ( | cs * | C | ) |
cs* cs_duplicate | ( | const cs * | b1 | ) |
int cs_entry2 | ( | cs * | T, |
int | i, | ||
int | j, | ||
double | x | ||
) |
bool cs_exist | ( | const cs * | A, |
int | row, | ||
int | col | ||
) |
cs* cs_extract_diag | ( | const cs * | C, |
int | oper_choice | ||
) |
cs* cs_extract_submatrix | ( | cs * | C, |
int | row_from, | ||
int | row_length, | ||
int | col_from, | ||
int | col_length | ||
) |
cs* cs_eye | ( | int | number, |
double | value | ||
) |
cs* cs_eye_tab | ( | int | number, |
double * | values | ||
) |
void cs_force_dimension | ( | cs * | T, |
int | nrow, | ||
int | ncol | ||
) |
int cs_get_ncell | ( | const cs * | A | ) |
int cs_get_ncol | ( | const cs * | A | ) |
int cs_get_nrow | ( | const cs * | A | ) |
int cs_get_status_update_nonzero_value | ( | ) |
double cs_get_value | ( | const cs * | A, |
int | row, | ||
int | col | ||
) |
void cs_gibbs | ( | const cs * | A, |
int | iech, | ||
const VectorDouble & | zcur, | ||
double * | yk, | ||
double * | sk | ||
) |
cs* cs_glue | ( | const cs * | A1, |
const cs * | A2, | ||
bool | shiftRow, | ||
bool | shiftCol | ||
) |
This method glues two sparse matrices into an output sparse matrix The second matrix is appended after addresses have been shifted either by row or by column
A1 | First sparse matrix |
A2 | Secon sparse matrix |
shiftRow | Shift A2 addresses by the number of rows of A1 |
shiftCol | Shift A2 addresses by the number of columns of A1 |
cs* cs_interpolate | ( | const cs * | AA, |
const cs * | Lt, | ||
const int * | Co | ||
) |
cs* cs_invert | ( | const cs * | A, |
int | order, | ||
double | epsilon | ||
) |
bool cs_isDefinitePositive | ( | cs * | A, |
bool | verbose | ||
) |
bool cs_isDiagonalDominant | ( | cs * | A, |
bool | verbose, | ||
bool | detail | ||
) |
bool cs_isSymmetric | ( | const cs * | A, |
bool | verbose, | ||
bool | detail | ||
) |
int cs_lsolve_lowtri | ( | const cs * | L, |
const double * | x, | ||
double * | y | ||
) |
int cs_lsolve_uptri | ( | const cs * | L, |
const double * | x, | ||
double * | y | ||
) |
cs* cs_matvecL | ( | const cs * | A, |
const double * | x, | ||
int | oper_choice | ||
) |
cs* cs_matvecnorm | ( | const cs * | A, |
const double * | x, | ||
int | oper_choice | ||
) |
void cs_matvecnorm_inplace | ( | cs * | A, |
const double * | x, | ||
int | oper_choice | ||
) |
cs* cs_matvecR | ( | const cs * | A, |
const double * | x, | ||
int | oper_choice | ||
) |
double cs_maxsumabscol | ( | const cs * | A | ) |
Compute the max along the lines of the sum of the absolute values along the columns
void cs_multigrid_coarse2fine | ( | cs_MGS * | mgs, |
double * | z, | ||
double * | work | ||
) |
Convert results from coarsest to final scale
[in] | mgs | cs_MGS structure |
[in,out] | z | Input vector |
[out] | work | Working array |
int cs_multigrid_get_nlevels | ( | cs_MGS * | mgs | ) |
Returns the number of multigrid levels
[in] | mgs | cs_MGS structure |
Allocate the structure for the multigrid manipulation
[in] | mgs | cs_MGS structure |
[in] | mode | 1 for allocation; -1 for deallocation |
[in] | nlevels | Number of levels of the multigrid (only for mode > 0) |
[in] | path_type | Type of the Path (1:V; 2:W, 3:F) (only for mode > 0) |
void cs_multigrid_params | ( | cs_MGS * | mgs, |
int | flag_cg, | ||
int | type_coarse, | ||
int | ngc, | ||
int | nmg, | ||
int | ngs, | ||
double | tolcg, | ||
double | tolnmg | ||
) |
Define the parameters for the multigrid manipulation
[in] | mgs | cs_MGS structure |
[in] | flag_cg | 1 for Conjugate-Gradient use; 0 otherwise |
[in] | type_coarse | Type of coarsening algorithm |
[in] | ngc | Maximum number of Conjugate-Gradient iterations |
[in] | nmg | Maximum number of mutligrid iterations |
[in] | ngs | Number of Gauss-Siedel relaxation cycles |
[in] | tolcg | Tolerance for the Conjugate-Gradient algorithm |
[in] | tolnmg | Tolerance for the Multigrid algorithm |
void cs_multigrid_print | ( | cs_MGS * | mgs | ) |
cs* cs_multiply2 | ( | const cs * | A, |
const cs * | B | ||
) |
cs* cs_multiply_and_release | ( | cs * | b1, |
const cs * | b2, | ||
int | flag_release | ||
) |
void cs_mulvec_lowtri | ( | const cs * | A, |
int | nout, | ||
const double * | x, | ||
double * | y, | ||
int | flag_diag | ||
) |
void cs_mulvec_uptri | ( | const cs * | A, |
int | nout, | ||
const double * | x, | ||
double * | y, | ||
int | flag_diag | ||
) |
csn* cs_nfree2 | ( | csn * | N | ) |
int cs_nnz | ( | const cs * | A | ) |
cs* cs_normalize_by_diag_and_release | ( | cs * | Q, |
int | flag_release | ||
) |
int cs_print2 | ( | const cs * | A, |
int | brief | ||
) |
void cs_print_dim | ( | const char * | title, |
const cs * | A | ||
) |
void cs_print_file | ( | const char * | radix, |
int | rank, | ||
const cs * | A | ||
) |
void cs_print_nice | ( | const char * | title, |
const cs * | A, | ||
int | maxrow, | ||
int | maxcol | ||
) |
void cs_print_only | ( | const char * | title, |
const cs * | A, | ||
int | nlimit | ||
) |
void cs_print_range | ( | const char * | title, |
const cs * | C | ||
) |
void cs_print_short | ( | const char * | title, |
const cs * | L, | ||
int | nmax | ||
) |
cs* cs_prod_norm | ( | int | mode, |
const cs * | A, | ||
const cs * | B | ||
) |
cs* cs_prod_norm_and_release | ( | cs * | b1, |
cs * | lambda, | ||
int | flag_release | ||
) |
cs* cs_prod_norm_diagonal | ( | int | mode, |
const cs * | B, | ||
const VectorDouble & | diag | ||
) |
cs* cs_prod_norm_single | ( | int | mode, |
const cs * | B | ||
) |
void cs_rowcol | ( | const cs * | A, |
int * | nrows, | ||
int * | ncols, | ||
int * | count, | ||
double * | percent | ||
) |
int cs_scale | ( | const cs * | A | ) |
void cs_set_cste | ( | const cs * | A, |
double | value | ||
) |
void cs_set_status_update_nonzero_value | ( | int | status | ) |
Define the status when modifying the value of a nonzero element of the sparse matrix
status | 0 (no test); 1 (warning issued); 2 (throw issued) |
void cs_set_value | ( | const cs * | A, |
int | row, | ||
int | col, | ||
double | value | ||
) |
css* cs_sfree2 | ( | css * | S | ) |
int cs_sort_i | ( | cs * | C | ) |
cs* cs_spalloc2 | ( | int | m, |
int | n, | ||
int | nzmax, | ||
int | values, | ||
int | triplet | ||
) |
cs* cs_spfree2 | ( | cs * | A | ) |
TODO : cs_*2 functions to be removed (encapsulation)
cs* cs_strip | ( | cs * | A, |
double | eps, | ||
int | hypothesis, | ||
bool | verbose | ||
) |
Strip off elements of the input Sparse Matrix whose absolute value is smaller than eps. Return a new compressed sparse matrix. Consequently, strip off the vector P[in/out] which contains the order of the samples
A | Input sparse matrix |
eps | Tolerance on absolute value of the input sparse matrix elements |
hypothesis | Stripping hypothesis |
verbose | Verbose flag |
double* cs_toArray | ( | const cs * | A | ) |
cs* cs_transpose2 | ( | const cs * | A, |
int | values | ||
) |
cs* cs_triangle | ( | cs * | A, |
int | flag_upper, | ||
int | flag_diag | ||
) |
cs* cs_triplet2 | ( | const cs * | T | ) |
void cs_vector_addToDest_Mx | ( | const cs * | A, |
int | nout, | ||
const double * | x, | ||
double * | y | ||
) |
void cs_vector_addToDest_tMx | ( | const cs * | A, |
int | nout, | ||
const double * | x, | ||
double * | y | ||
) |
void cs_vector_Mx | ( | const cs * | A, |
int | nout, | ||
const double * | x, | ||
double * | y | ||
) |
void cs_vector_tMx | ( | const cs * | A, |
int | nout, | ||
const double * | x, | ||
double * | y | ||
) |
void cs_vector_xM | ( | const cs * | A, |
int | nout, | ||
const double * | x, | ||
double * | y | ||
) |
void cs_vector_xtM | ( | const cs * | A, |
int | nout, | ||
const double * | x, | ||
double * | y | ||
) |
MatrixSparse* cs_vectors_to_sparse | ( | int | nrow, |
int | ncol, | ||
const VectorDouble & | rows, | ||
const VectorDouble & | cols, | ||
const VectorDouble & | values | ||
) |
double* csd_extract_diag | ( | const cs * | C, |
int | oper_choice | ||
) |
VectorDouble csd_extract_diag_VD | ( | const cs * | C, |
int | oper_choice | ||
) |
NF_Triplet csToTriplet | ( | const cs * | A, |
int | shiftRow, | ||
int | shiftCol, | ||
double | tol | ||
) |
int qchol_cholesky | ( | int | verbose, |
QChol * | QC | ||
) |
Finalize the construction of the QChol structure. Perform the Cholesky decomposition
[in] | verbose | Verbose flag |
[in] | QC | QChol structure to be finalized |
|
static |
|
static |
|
static |
Allocate one sub-structure for the multigrid manipulation
[in] | mode | 1 for allocation; -1 for deallocation |
[in] | mg | cs_MG structure (used for deallocation) |
|
static |
Ascent step
[in] | mgs | cs_MGS structure |
[in] | level | Current level |
[in] | flag_init | 1 if the output vector must be initialized |
[in] | flag_scale | 1 if the output vector must be scaled |
[in] | zin | Input vector |
[out] | zout | Output vector |
[out] | work | Working array |
|
static |
Descent step
[in] | mgs | cs_MGS structure |
[in] | level | Current level |
[in] | zin | Input vector |
[in] | rhsin | Input R.H.S. vector |
[out] | rhsout | Output R.H.S. vector |
[out] | work | Working array |
|
static |
Conjugate Gradient algorithm for the multigrid kriging
[in] | mgs | cs_MGS structure |
[in] | verbose | Verbose flag |
[in,out] | x | Input vector |
[in] | b | R.H.S. vector |
[out] | work | Working array |
|
static |
Iterative phases for the multigrid kriging
[in] | mgs | cs_MGS structure |
[in] | verbose | Verbose flag |
[in,out] | x | Input vector |
[in] | b | R.H.S. vector |
[out] | work | Working array |
|
static |
Normalize / Denormalize the initial solution and RHS for the multigrid kriging
[in] | mgs | cs_MGS structure |
[in] | mode | 1 : Normalize; -1 : Denormalize |
[in] | z | Solution vector |
[in] | b | Right-hand side |
|
static |
Define the default parameters for the Multigrid option
[in] | mgs | cs_MGS structure |
|
static |
Define the path according to the number of levels
[in] | mgs | cs_MGS structure |
[in] | nlevels | Number of coarsening levels |
[in] | path_type | Type of the path |
|
static |
Print the path
|
static |
Relaxation step
[in] | mgs | cs_MGS structure |
[in] | level | Current level |
[in] | mode | 1 for Descending and -1 for Ascending |
[in,out] | xcr | Current vector |
[in] | rhs | Current R.H.S. vector |
[out] | work | Working array |
|
static |
|
static |
|
static |