#include "geoslib_f.h"
#include "geoslib_f_private.h"
#include "geoslib_old_f.h"
#include "geoslib_enum.h"
#include "Enum/ELoadBy.hpp"
#include "Matrix/MatrixFactory.hpp"
#include "Matrix/MatrixSquareGeneral.hpp"
#include "Matrix/MatrixSparse.hpp"
#include "Matrix/LinkMatrixSparse.hpp"
#include "Matrix/NF_Triplet.hpp"
#include "LinearOp/ProjMatrix.hpp"
#include "Model/NoStatArray.hpp"
#include "Mesh/MeshEStandard.hpp"
#include "Covariances/CovAniso.hpp"
#include "Covariances/ACovAnisoList.hpp"
#include "Covariances/CovFactory.hpp"
#include "Basic/AException.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/Law.hpp"
#include "Basic/MathFunc.hpp"
#include "Basic/File.hpp"
#include "Basic/String.hpp"
#include "Basic/VectorHelper.hpp"
#include "Db/Db.hpp"
#include "Model/Model.hpp"
#include "Mesh/AMesh.hpp"
#include "Mesh/MeshETurbo.hpp"
#include "Calculators/CalcMigrate.hpp"
#include "Space/SpaceSN.hpp"
#include "Geometry/GeometryHelper.hpp"
#include <math.h>
#include <string.h>
#include "csparse_f.h"
Macros | |
#define | NBLIN_TERMS 10 |
#define | SPDE_MAX_NGRF 2 |
Functions | |
void | spde_option_update (SPDE_Option &s_option, const String &triswitch) |
SPDE_Option | spde_option_alloc (void) |
SPDE_Matelem & | spde_get_current_matelem (int icov) |
void | simu_define_func_transf (void(*st_simu_transf)(Db *, int, int, int)) |
void | simu_define_func_update (void(*st_simu_update)(Db *, int, int, int)) |
void | simu_define_func_scale (void(*st_simu_scale)(Db *, int, int)) |
QChol * | qchol_manage (int mode, QChol *QC) |
double | spde_compute_correc (int ndim, double param) |
int | spde_attach_model (Model *model) |
int | spde_build_stdev (double *vcur) |
double * | _spde_get_mesh_dimension (AMesh *amesh) |
MatrixSparse * | _spde_fill_S (AMesh *amesh, Model *model, double *units) |
VectorDouble | _spde_fill_TildeC (AMesh *amesh, double *units) |
VectorDouble | _spde_fill_Lambda (Model *model, AMesh *amesh, const VectorDouble &TildeC) |
MatrixSparse * | _spde_build_Q (MatrixSparse *S, const VectorDouble &Lambda, int nblin, double *blin) |
int | spde_build_matrices (Model *model, int verbose) |
int | spde_chebychev_operate (MatrixSparse *S, Cheb_Elem *cheb_elem, const VectorDouble &lambda, const VectorDouble &x, VectorDouble &y) |
Cheb_Elem * | spde_cheb_manage (int mode, int verbose, double power, const VectorDouble &blin, MatrixSparse *S, Cheb_Elem *cheb_old) |
Cheb_Elem * | _spde_cheb_duplicate (Cheb_Elem *cheb_in) |
int | spde_process (Db *dbin, Db *dbout, SPDE_Option &s_option, int nbsimu, int ngibbs_burn, int ngibbs_iter, int ngibbs_int) |
int | spde_external_copy (SPDE_Matelem &matelem, int icov0) |
AMesh * | spde_mesh_load (Db *dbin, Db *dbout, const VectorDouble &gext, SPDE_Option &s_option, bool verbose) |
void | spde_external_mesh_define (int icov0, AMesh *mesh) |
void | spde_external_mesh_undefine (int icov0) |
MatrixSparse * | spde_external_A_define (int icov0, MatrixSparse *A) |
MatrixSparse * | spde_external_A_undefine (int icov0) |
MatrixSparse * | spde_external_Q_define (int icov0, MatrixSparse *Q) |
MatrixSparse * | spde_external_Q_undefine (int icov0) |
void | spde_mesh_assign (AMesh *amesh, int ndim, int ncorner, int nvertex, int nmesh, const VectorInt &arg_meshes, const VectorDouble &arg_points, int verbose) |
int | spde_prepar (Db *dbin, Db *dbout, const VectorDouble &gext, SPDE_Option &s_option) |
int | spde_posterior () |
void | spde_free_all (void) |
int | spde_check (const Db *dbin, const Db *dbout, Model *model1, Model *model2, bool verbose, const VectorDouble &gext, bool mesh_dbin, bool mesh_dbout, bool flag_advanced, bool flag_est, bool flag_std, bool flag_gibbs, bool flag_modif) |
int | kriging2D_spde (Db *dbin, Model *model, SPDE_Option &s_option, int verbose, int *nmesh_arg, int *nvertex_arg, VectorInt &meshes_arg, VectorDouble &points_arg) |
int | spde_eval (const VectorDouble &blin, MatrixSparse *S, const VectorDouble &Lambda, const VectorDouble &TildeC, double power, VectorDouble &x, VectorDouble &y) |
MatrixSparse * | db_mesh_neigh (const Db *db, AMesh *amesh, double radius, int flag_exact, bool, int *nactive_arg, int **ranks_arg) |
int | m2d_gibbs_spde (Db *dbin, Db *dbout, Model *model, int flag_ed, int nlayer, int niter, int seed, int nbsimu, int icol_pinch, int flag_drift, int flag_ce, int flag_cstd, int verbose) |
#define NBLIN_TERMS 10 |
#define SPDE_MAX_NGRF 2 |
MatrixSparse* _spde_build_Q | ( | MatrixSparse * | S, |
const VectorDouble & | Lambda, | ||
int | nblin, | ||
double * | blin | ||
) |
Duplicate a Cheb_Elem structure
[in] | cheb_in | Input Cheb_Eleme structure |
VectorDouble _spde_fill_Lambda | ( | Model * | model, |
AMesh * | amesh, | ||
const VectorDouble & | TildeC | ||
) |
Fill the vector for sill correction factors Works for both stationary and non-stationary cases
[in] | model | Model structure |
[in] | amesh | MeshEStandard structure |
[in] | TildeC | Vector TildeC |
MatrixSparse* _spde_fill_S | ( | AMesh * | amesh, |
Model * | model, | ||
double * | units | ||
) |
VectorDouble _spde_fill_TildeC | ( | AMesh * | amesh, |
double * | units | ||
) |
Fill the vector TildeC (Dimension: nvertex)
[in] | amesh | MeshEStandard structure |
[in] | units | Array containing the element units |
double* _spde_get_mesh_dimension | ( | AMesh * | amesh | ) |
Calculate the array of dimensions of the meshes
[in] | amesh | MeshEStandard structure |
MatrixSparse* db_mesh_neigh | ( | const Db * | db, |
AMesh * | amesh, | ||
double | radius, | ||
int | flag_exact, | ||
bool | , | ||
int * | nactive_arg, | ||
int ** | ranks_arg | ||
) |
Returns the projection matrix of a set of points (contained in a Db) onto a meshing
[in] | db | Db structure |
[in] | amesh | AMesh structure |
[in] | flag_exact | Type of test for intersection (See remarks) |
[in] | radius | Neighborhood radius |
[out] | nactive_arg | Number of active samples from the Db |
[out] | ranks_arg | Ranks of the active samples |
int kriging2D_spde | ( | Db * | dbin, |
Model * | model, | ||
SPDE_Option & | s_option, | ||
int | verbose, | ||
int * | nmesh_arg, | ||
int * | nvertex_arg, | ||
VectorInt & | meshes_arg, | ||
VectorDouble & | points_arg | ||
) |
Perform Kriging using SPDE on the set of constructed 2-D triangles
[in] | dbin | Db input structure |
[in] | model | Model structure |
[in] | s_option | SPDE_Option structure |
[in] | verbose | Verbose option |
[out] | nmesh_arg | Number of triangles generated |
[out] | nvertex_arg | Number of vertices |
[out] | meshes_arg | Array of triangulate vertex indices |
[out] | points_arg | Array containing the 2-D vertices |
int m2d_gibbs_spde | ( | Db * | dbin, |
Db * | dbout, | ||
Model * | model, | ||
int | flag_ed, | ||
int | nlayer, | ||
int | niter, | ||
int | seed, | ||
int | nbsimu, | ||
int | icol_pinch, | ||
int | flag_drift, | ||
int | flag_ce, | ||
int | flag_cstd, | ||
int | verbose | ||
) |
Perform Gibbs on a multilayer setup
[in] | dbin | Db input structure |
[in] | dbout | Db output structure |
[in] | model | Model structure |
[in] | flag_ed | 1 if External Drit is used |
[in] | nlayer | Number of layers |
[in] | niter | Number of iterations |
[in] | seed | Seed for random number generator |
[in] | nbsimu | Number of simulaations |
[in] | icol_pinch | Address of the variable containing the pinchout |
[in] | flag_drift | 1 to return the drift only 0 the simulations |
[in] | flag_ce | 1 if the conditional expectation should be returned instead of simulations |
[in] | flag_cstd | 1 if the conditional standard deviation should be returned instead of simulations |
[in] | verbose | Verbose option |
void simu_define_func_scale | ( | void(*)(Db *, int, int) | st_simu_scale | ) |
Define the function to scale the Modification arrays
[in] | st_simu_scale | Pointer to the scaling function |
void simu_define_func_transf | ( | void(*)(Db *, int, int, int) | st_simu_transf | ) |
Define the function to transform a simulation
[in] | st_simu_transf | Pointer to the transformation function |
void simu_define_func_update | ( | void(*)(Db *, int, int, int) | st_simu_update | ) |
Define the function to account for the current simulation outcome in the calculation of the Modification arrays
[in] | st_simu_update | Pointer to the update function |
int spde_attach_model | ( | Model * | model | ) |
int spde_build_matrices | ( | Model * | model, |
int | verbose | ||
) |
Build all matrices needed for establishing the Q sparse matrix
[in] | model | Model structure |
[in] | verbose | Verbose option |
int spde_build_stdev | ( | double * | vcur | ) |
Perform the calculation of the Standard Deviation of Estimation Error
[out] | vcur | Output array |
Cheb_Elem* spde_cheb_manage | ( | int | mode, |
int | verbose, | ||
double | power, | ||
const VectorDouble & | blin, | ||
MatrixSparse * | S, | ||
Cheb_Elem * | cheb_old | ||
) |
Manage Cheb_Elem structure
[in] | mode | 1 for allocation; -1 for deallocation |
[in] | verbose | Verbose flag |
[in] | power | Parameter passed to Chebychev function |
[in] | blin | Array of coefficients for Linear combinaison |
[in] | S | Shift operator |
[in] | cheb_old | Cheb_Elem to be freed (only for mode=-1) |
int spde_chebychev_operate | ( | MatrixSparse * | S, |
Cheb_Elem * | cheb_elem, | ||
const VectorDouble & | lambda, | ||
const VectorDouble & | x, | ||
VectorDouble & | y | ||
) |
int spde_check | ( | const Db * | dbin, |
const Db * | dbout, | ||
Model * | model1, | ||
Model * | model2, | ||
bool | verbose, | ||
const VectorDouble & | gext, | ||
bool | mesh_dbin, | ||
bool | mesh_dbout, | ||
bool | flag_advanced, | ||
bool | flag_est, | ||
bool | flag_std, | ||
bool | flag_gibbs, | ||
bool | flag_modif | ||
) |
Define the main options
[in] | dbin | Pointer to the input Db |
[in] | dbout | Pointer to the output Db |
[in] | model1 | Model structure (first) |
[in] | model2 | Model structure (second) |
[in] | verbose | Verbose flag |
[in] | gext | Array of domain dilation |
[in] | mesh_dbin | True if Input points must participate to meshing |
[in] | mesh_dbout | True if Output points must participate to meshing |
[in] | flag_advanced | True for advanced calculus (estimation or simulation) False if only matrices are required |
[in] | flag_est | True for estimation |
[in] | flag_std | True for standard deviation |
[in] | flag_gibbs | True for Gibbs sampler |
[in] | flag_modif | True for post-processing simulations |
double spde_compute_correc | ( | int | ndim, |
double | param | ||
) |
int spde_eval | ( | const VectorDouble & | blin, |
MatrixSparse * | S, | ||
const VectorDouble & | Lambda, | ||
const VectorDouble & | TildeC, | ||
double | power, | ||
VectorDouble & | x, | ||
VectorDouble & | y | ||
) |
Perform the product of a vector by the inverse of the power of a sparse matrix using the Chebychev Polynomial procedure
MatrixSparse* spde_external_A_define | ( | int | icov0, |
MatrixSparse * | A | ||
) |
MatrixSparse* spde_external_A_undefine | ( | int | icov0 | ) |
int spde_external_copy | ( | SPDE_Matelem & | matelem, |
int | icov0 | ||
) |
Copy the contents of the internal S_EXTERNAL_AQ into an output Matelem
Error return code
[in] | matelem | Output SPDE_Matelem structure |
[in] | icov0 | Rank of the current Covariance |
void spde_external_mesh_define | ( | int | icov0, |
AMesh * | mesh | ||
) |
void spde_external_mesh_undefine | ( | int | icov0 | ) |
MatrixSparse* spde_external_Q_define | ( | int | icov0, |
MatrixSparse * | Q | ||
) |
MatrixSparse* spde_external_Q_undefine | ( | int | icov0 | ) |
void spde_free_all | ( | void | ) |
Free all memory used in SPDE
SPDE_Matelem& spde_get_current_matelem | ( | int | icov | ) |
Get the pointer to the current SPDE_Matelem structure
[in] | icov | Rank of the target Covariance (or -1)typedef struct |
void spde_mesh_assign | ( | AMesh * | amesh, |
int | ndim, | ||
int | ncorner, | ||
int | nvertex, | ||
int | nmesh, | ||
const VectorInt & | arg_meshes, | ||
const VectorDouble & | arg_points, | ||
int | verbose | ||
) |
Assign fields of the AMesh structure which would have been calculated elsewhere
AMesh* spde_mesh_load | ( | Db * | dbin, |
Db * | dbout, | ||
const VectorDouble & | gext, | ||
SPDE_Option & | s_option, | ||
bool | verbose | ||
) |
SPDE_Option spde_option_alloc | ( | void | ) |
Manage the SPDE_Option structure
void spde_option_update | ( | SPDE_Option & | s_option, |
const String & | triswitch | ||
) |
Add a new option item for an additional covariance structure
[in] | s_option | Pointer to SPDE_Option to be freed (if mode<0) |
[in] | triswitch | String defining the meshing characteristics |
int spde_posterior | ( | ) |
Cleaning operation after SPDE
int spde_prepar | ( | Db * | dbin, |
Db * | dbout, | ||
const VectorDouble & | gext, | ||
SPDE_Option & | s_option | ||
) |
Preparation using SPDE (for all GRF and COV)
[in] | dbin | Db structure for the conditioning data |
[in] | dbout | Db structure of the grid |
[in] | gext | Array of domain dilation |
[in] | s_option | SPDE_Option structure |
int spde_process | ( | Db * | dbin, |
Db * | dbout, | ||
SPDE_Option & | s_option, | ||
int | nbsimu, | ||
int | ngibbs_burn, | ||
int | ngibbs_iter, | ||
int | ngibbs_int | ||
) |
Perform the main Simulations steps after Q has been constructed
[in] | dbin | Input Db grid structure (optional) |
[in] | dbout | Output Db grid structure |
[in] | s_option | SPDE_Option structure |
[in] | nbsimu | Number of simulations |
[in] | ngibbs_burn | Number of iterations (Burning step) |
[in] | ngibbs_iter | Number of iterations |
[in] | ngibbs_int | Number of iterations internal to Gibbs (SPDE) |