#include "geoslib_old_f.h"
#include "Basic/Utilities.hpp"
#include "Basic/Law.hpp"
#include "Basic/OptDbg.hpp"
#include "Core/Potential.hpp"
#include "Covariances/CovAniso.hpp"
#include "Covariances/CovLMGradient.hpp"
#include "Drifts/DriftList.hpp"
#include "Db/Db.hpp"
#include "Db/DbGrid.hpp"
#include "Db/DbHelper.hpp"
#include "Model/Model.hpp"
#include "Neigh/ANeigh.hpp"
#include "Matrix/MatrixFactory.hpp"
#include "Simulation/CalcSimuTurningBands.hpp"
#include "Basic/Memory.hpp"
#include <math.h>
#include <string.h>
Functions | |
static void | st_potenv_define (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, Db *dbout) |
static int | GRX (int i) |
static int | GRY (int i) |
static int | GRZ (int i) |
static int | TGT (int i) |
static int | ISC (int ic, int i) |
static int | IAD_GRD (int ig) |
static void | set_IAD_GRD (int ig, int value) |
static int | IAD_TGT (int it) |
static void | set_IAD_TGT (int it, int value) |
static double | IAD_ISO (int ic, int i) |
static double | TGT_COO (int it, int i) |
static double | TGT_VAL (int it, int idim) |
static double | GRD_COO (int ig, int idim) |
static double | GRD_VAL (int ig, int idim) |
static double | ISO_COO (int ic, int j, int idim) |
static int | EXT (int iext) |
static int | st_model_invalid (Model *model) |
static void | st_cov (Model *model, bool flag_grad, double dx, double dy, double dz, double &covar, VectorDouble &covGp, VectorDouble &covGG) |
static int | st_extdrift_create_db (DbGrid *dbout, Pot_Ext *pot_ext) |
static int | st_extdrift_create_model (Pot_Ext *pot_ext) |
static MatrixRectangular | st_extdrift_establish (Pot_Ext *pot_ext, int number) |
static int | st_extdrift_calc_init (DbGrid *dbout, Pot_Ext *pot_ext) |
static int | st_potext_manage (int mode, Pot_Ext *pot_ext, int nring, double range, DbGrid *dbout) |
bool | st_potenv_valid (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbout, Model *model, ANeigh *neigh) |
static void | st_potenv_manage (Pot_Env *pot_env, bool flag_pot, bool flag_grad, bool flag_trans, int opt_part, bool verbose) |
static int | st_update_isopot (Db *dbiso, Pot_Env *pot_env) |
static int | st_update_gradient (Db *dbgrd, Pot_Env *pot_env) |
static int | st_update_tangent (Db *dbtgt, Pot_Env *pot_env) |
static int | st_update_model (Model *model, Pot_Env *pot_env) |
static int | st_update_final (Model *model, Pot_Env *pot_env) |
static double | setMatUV (int ndim, double ux, double uy, double uz, double vx, double vy, double vz) |
static double | setMatUAV (int ndim, const double *a, double ux, double uy, double uz, double vx, double vy, double vz) |
static void | setRhs (MatrixRectangular &rhs, int i, int isol, double value) |
static void | setLhs (MatrixSquareSymmetric &lhs, int i, int j, double value) |
static double | getLhs (MatrixSquareSymmetric &lhs, int i, int j) |
static int | st_extdrift_neigh (DbGrid *dbgrid, Pot_Ext *pot_ext) |
static int | st_extdrift_eval (const char *target, double x0, double y0, double z0, DbGrid *dbgrid, Pot_Ext *pot_ext, double *extval, VectorDouble &extgrd) |
static int | st_build_lhs (Pot_Env *pot_env, Pot_Ext *pot_ext, DbGrid *dbout, Model *model, double nugget_grd, double nugget_tgt, MatrixSquareSymmetric &lhs) |
static void | st_fill_dual (Pot_Env *pot_env, VectorDouble &zval) |
static void | st_fill_dual_simulation (Pot_Env *pot_env, Db *dbiso, Db *dbgrd, Db *dbtgt, int nbsimu, MatrixRectangular &zvals) |
static void | st_rhs_part (Pot_Env *pot_env, MatrixRectangular &rhs) |
static void | st_build_rhs (Pot_Env *pot_env, Pot_Ext *pot_ext, bool flag_grad, DbGrid *dbgrid, Model *model, VectorDouble &coor, MatrixRectangular &rhs) |
static void | st_calc_point (Pot_Env *pot_env, Pot_Ext *pot_ext, bool flag_grad, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbgrid, Model *model, VectorDouble &zdual, MatrixRectangular &rhs, Db *db_target, int iech0, VectorDouble &result) |
static void | st_potential_to_layer (Pot_Env *pot_env, int isimu, const double *potval, VectorDouble &result) |
static void | st_estimate_result (Pot_Env *pot_env, Pot_Ext *pot_ext, bool flag_grad, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbout, Model *model, double refpot, VectorDouble &zdual, MatrixRectangular &rhs, double *potval) |
static void | st_estimate_data (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbout, Model *model, double refpot, VectorDouble &zdual, MatrixRectangular &rhs, Db *db_target, VectorInt &uid_pot, VectorInt &uid_grad) |
static void | st_dist_convert (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, Model *model, int ic0, int j0, VectorDouble &zval, MatrixSquareSymmetric &lhs_orig_arg, MatrixRectangular &rhs_arg, double *dist_euc, double *dist_geo) |
static void | st_xvalid_potential (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, Model *model, MatrixSquareSymmetric &lhs, bool flag_dist_conv, VectorDouble &zval, MatrixSquareSymmetric &lhs_orig, MatrixRectangular &rhs, VectorDouble &zdual) |
static void | st_tempere (DbGrid *dbout, int iech, double dist_tempere, double reskrige, VectorDouble &result) |
static void | st_simcond (Pot_Env *pot_env, Pot_Ext *pot_ext, double dist_tempere, bool flag_trans, int nbsimu, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbout, Model *model, double refpot, double *potsim, VectorDouble &zdual, MatrixRectangular &zduals, MatrixRectangular &rhs) |
static void | st_print_result (Pot_Env *pot_env, int isimu, double *result, double tgtval) |
static void | st_check_data (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbgrid, Model *model, int isimu, int nbsimu, double refpot, VectorDouble &zdual, MatrixRectangular &rhs) |
static double | st_evaluate_refpot (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbgrid, Model *model, VectorDouble &zdual, MatrixRectangular &rhs) |
static void | st_evaluate_potval (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbgrid, Model *model, double refpot, int isimu, int nbsimu, VectorDouble &zdual, MatrixRectangular &rhs, double *potval) |
static void | st_save_result_on_data (Pot_Env *pot_env, Db *db, int nvar, double value, const ELoc &loctype_pot, const ELoc &loctype_grad, VectorInt &uid_pot, VectorInt &uid_grad) |
int | potential_kriging (Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbout, Model *model, ANeigh *neigh, double nugget_grd, double nugget_tgt, bool flag_pot, bool flag_grad, bool flag_trans, bool flag_save_data, int opt_part, bool verbose) |
static int | st_distance_to_isoline (DbGrid *dbout) |
int | potential_simulate (Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbout, Model *model, ANeigh *neigh, double nugget_grd, double nugget_tgt, double dist_tempere, bool flag_trans, int seed, int nbsimu, int nbtuba, bool verbose) |
int | potential_xvalid (Db *dbiso, Db *dbgrd, Db *dbtgt, Model *model, ANeigh *neigh, double nugget_grd, double nugget_tgt, bool flag_dist_conv, bool verbose) |
static void | st_print_type (int rank, int type) |
int | potential_cov (Model *model, bool verbose, int type1, const VectorDouble &x10, const VectorDouble &x1p, const VectorDouble &tx1, int type2, const VectorDouble &x20, const VectorDouble &x2p, const VectorDouble &tx2, VectorDouble &covtab) |
|
static |
|
static |
Get one element from the Kriging L.H.S. matrix
[in] | lhs | Matrix to be filled |
[in] | i | Row number |
[in] | j | Column number |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
int potential_cov | ( | Model * | model, |
bool | verbose, | ||
int | type1, | ||
const VectorDouble & | x10, | ||
const VectorDouble & | x1p, | ||
const VectorDouble & | tx1, | ||
int | type2, | ||
const VectorDouble & | x20, | ||
const VectorDouble & | x2p, | ||
const VectorDouble & | tx2, | ||
VectorDouble & | covtab | ||
) |
Potential covariance
[in] | model | Model structure |
[in] | verbose | Verbose flag |
[in] | type1 | Type of the first point 1 for gradient; 2 for tangent; 3 for isopotential |
[in] | x10 | Coordinates of the centering for first point |
[in] | x1p | Coordinates of the first point |
[in] | tx1 | Tangent values at the first point |
[in] | type2 | Type of the second point 1 for gradient; 2 for tangent; 3 for isopotential (Sign is negative for target point) |
[in] | x20 | Coordinates of the centering for second point |
[in] | x2p | Coordinates of the second point |
[in] | tx2 | Tangent values at the second point |
[out] | covtab | Array of returned values (dimensionned to ndim*ndim) |
int potential_kriging | ( | Db * | dbiso, |
Db * | dbgrd, | ||
Db * | dbtgt, | ||
DbGrid * | dbout, | ||
Model * | model, | ||
ANeigh * | neigh, | ||
double | nugget_grd, | ||
double | nugget_tgt, | ||
bool | flag_pot, | ||
bool | flag_grad, | ||
bool | flag_trans, | ||
bool | flag_save_data, | ||
int | opt_part, | ||
bool | verbose | ||
) |
Potential estimation
[in] | dbiso | Iso-potential Db structure |
[in] | dbgrd | Gradient Db structure |
[in] | dbtgt | Tangent Db structure (optional) |
[in] | dbout | Output Db structure |
[in] | model | Model structure |
[in] | neigh | ANeigh structure |
[in] | nugget_grd | Nugget effect for Gradients |
[in] | nugget_tgt | Nugget effect for Tangents |
[in] | flag_pot | True if the Potential must be estimated |
[in] | flag_grad | True if the gradient must also be estimated |
[in] | flag_trans | True if the estimation result must be translated into layer number |
[in] | flag_save_data | True if the Potential / Gradient must be saved on any Information file |
[in] | opt_part | Option to exhibit only a part of estimation:
|
[in] | verbose | Verbose option |
int potential_simulate | ( | Db * | dbiso, |
Db * | dbgrd, | ||
Db * | dbtgt, | ||
DbGrid * | dbout, | ||
Model * | model, | ||
ANeigh * | neigh, | ||
double | nugget_grd, | ||
double | nugget_tgt, | ||
double | dist_tempere, | ||
bool | flag_trans, | ||
int | seed, | ||
int | nbsimu, | ||
int | nbtuba, | ||
bool | verbose | ||
) |
Potential simulations
[in] | dbiso | Iso-potential Db structure |
[in] | dbgrd | Gradient Db structure |
[in] | dbtgt | Tangent Db structure (optional) |
[in] | dbout | Output Db structure |
[in] | model | Model structure |
[in] | neigh | ANeigh structure |
[in] | nugget_grd | Nugget effect for Gradients |
[in] | nugget_tgt | Nugget effect for Tangents |
[in] | dist_tempere | Distance for tempering simulations (or TEST) |
[in] | flag_trans | True if the estimation result must be translated into layer number |
[in] | seed | Seed for the random number generator |
[in] | nbsimu | Number of simulations |
[in] | nbtuba | Number of turning bands |
[in] | verbose | Verbose option |
int potential_xvalid | ( | Db * | dbiso, |
Db * | dbgrd, | ||
Db * | dbtgt, | ||
Model * | model, | ||
ANeigh * | neigh, | ||
double | nugget_grd, | ||
double | nugget_tgt, | ||
bool | flag_dist_conv, | ||
bool | verbose | ||
) |
Potential cross-validation
[in] | dbiso | Iso-potential Db structure |
[in] | dbgrd | Gradient Db structure |
[in] | dbtgt | Tangent Db structure (optional) |
[in] | model | Model structure |
[in] | neigh | ANeigh structure |
[in] | nugget_grd | Nugget effect for Gradients |
[in] | nugget_tgt | Nugget effect for Tangents |
[in] | flag_dist_conv | Flag for converting into distance |
[in] | verbose | Verbose option |
|
static |
|
static |
|
static |
Set and element in the Kriging L.H.S. matrix
[in] | lhs | Matrix to be filled |
[in] | i | Row number |
[in] | j | Column number |
[in] | value | Value to be assigned to this cell |
|
static |
Calculate the norm product of two vectors by a matrix
[in] | ndim | : Space dimension |
[in] | a | : Matrix |
[in] | ux | : First coordinate of the first vector |
[in] | uy | : Second coordinate of the first vector |
[in] | uz | : Third coordinate of the first vector |
[in] | vx | : First coordinate of the second vector |
[in] | vy | : Second coordinate of the second vector |
[in] | vz | : Third coordinate of the second vector |
|
static |
Calculate the inner product of two vectors
[in] | ndim | : Space dimension |
[in] | ux | : First coordinate of the first vector |
[in] | uy | : Second coordinate of the first vector |
[in] | uz | : Third coordinate of the first vector |
[in] | vx | : First coordinate of the second vector |
[in] | vy | : Second coordinate of the second vector |
[in] | vz | : Third coordinate of the second vector |
|
static |
Set and element in the Kriging R.H.S. vector
[in] | rhs | Vector to be filled |
[in] | i | Row number |
[in] | isol | Column number |
[in] | value | Value to be assigned to this cell |
|
static |
Establish the cokriging system
[in] | pot_env | Pot_Env structure |
[in] | pot_ext | Pot_Ext structure |
[in] | dbout | Target Db structure (only used for external drift) |
[in] | model | Model structure |
[in] | nugget_grd | Nugget effect for Gradients |
[in] | nugget_tgt | Nugget effect for Tangents |
[out] | lhs | Cokriging matrix |
|
static |
Calculate the estimation and gradient components at one target location
|
static |
Calculate the estimation and gradient components at one target
[in] | pot_env | Pot_Env structure |
[in] | pot_ext | Pot_Ext structure |
[in] | flag_grad | True if the gradients must also be calculated |
[in] | dbiso | Iso-potential Db structure (not used) |
[in] | dbgrd | Gradient Db structure (not used) |
[in] | dbtgt | Tangent Db structure (not used) |
[in] | dbgrid | Output Db structure (for Ext Drift) |
[in] | model | Model structure |
[in] | zdual | Dual vector (Dimension: nequa) |
[in] | rhs | R.H.S. vector (Dimension: nequa * 4) |
[in] | db_target | Db corresponding to the target |
[in] | iech0 | Rank of the target sample |
[out] | result | Array of results (Dimension: nsol) |
|
static |
Calculate the estimation and gradient components at data information
[in] | pot_env | Pot_Env structure |
[in] | pot_ext | Pot_Ext structure |
[in] | dbiso | Iso-potential Db structure |
[in] | dbgrd | Gradient Db structure |
[in] | dbtgt | Tangent Db structure (optional) |
[in] | dbgrid | Output Db structure (for External drift) |
[in] | model | Model structure |
[in] | isimu | Rank of the simulation (or -1) |
[in] | nbsimu | Number of simulations |
[in] | refpot | Potential at Reference point |
[in] | zdual | Dual vector (Dimension: nequa) |
[in] | rhs | R.H.S. vector (Dimension: nequa * 4) |
|
static |
Calculate the covariance and the derivatives
[in] | model | Model structure |
[in] | flag_grad | True if the Gradients must be calculated |
[in] | dx | Increment along X |
[in] | dy | Increment along Y |
[in] | dz | Increment along Z |
[out] | covar | Covariance of potential |
[out] | covGp | Covariance between potential and gradient |
[out] | covGG | Covariance between gradient and gradient |
|
static |
Calculate the cross-validation at the iso-potential samples
[in] | pot_env | Pot_Env structure |
[in] | pot_ext | Pot_Ext structure |
[in] | dbiso | Iso-potential Db structure (not used) |
[in] | dbgrd | Gradient Db structure (not used) |
[in] | dbtgt | Tangent Db structure (not used) |
[in] | model | Model structure |
[in] | ic0 | Rank of the isoline |
[in] | j0 | Rank of the sample within this isoline |
[in] | zval | Data vector |
[in] | lhs_orig_arg | Copy of the initial LHS (non inverted) |
[in] | rhs_arg | Right-hand side |
[out] | dist_euc | Error converted into Euclidean distance |
[out] | dist_geo | Error converted into along surface distance |
|
static |
Transform the Estimation variable into a distance to the isoline
[in] | dbout | Output Db structure |
|
static |
|
static |
Calculate the estimation and/or gradient components at target samples
[in] | pot_env | Pot_Env structure |
[in] | pot_ext | Pot_Ext structure |
[in] | flag_grad | True if the gradients must also be calculated |
[in] | dbiso | Iso-potential Db structure |
[in] | dbgrd | Gradient Db structure |
[in] | dbtgt | Tangent Db structure (optional) |
[in] | dbout | Output Db structure |
[in] | model | Model structure |
[in] | refpot | Potential at Reference point |
[in] | zdual | Dual vector (Dimension: nequa) |
[in] | rhs | R.H.S. vector (Dimension: nequa * 4) |
[in] | potval | Potential values at iso-potential samples |
|
static |
Calculate the estimation at the iso-potential samples
[in] | pot_env | Pot_Env structure |
[in] | pot_ext | Pot_Ext structure |
[in] | dbiso | Iso-potential Db structure |
[in] | dbgrd | Gradient Db structure |
[in] | dbtgt | Tangent Db structure (optional) |
[in] | dbgrid | Ouput Db structure (for external drift) |
[in] | model | Model structure |
[in] | refpot | Potential at Reference point |
[in] | isimu | Rank of the simulation (or -1) |
[in] | nbsimu | Number of simulations (or 0) |
[in] | zdual | Dual vector (Dimension: nequa) |
[in] | rhs | R.H.S. vector (Dimension: nequa * 4) |
[out] | potval | Array of Potential values |
|
static |
Calculate the estimation at the potential at first point of first potential
[in] | pot_env | Pot_Env structure |
[in] | pot_ext | Pot_Ext structure |
[in] | dbiso | Iso-potential Db structure |
[in] | dbgrd | Gradient Db structure |
[in] | dbtgt | Tangent Db structure (optional) |
[in] | dbgrid | Ouput Db structure (for external drift) |
[in] | model | Model structure |
[in] | zdual | Dual vector (Dimension: nequa) |
[in] | rhs | R.H.S. vector (Dimension: nequa * 4) |
|
static |
Establish kriging system for calculating Gradient on External Drift
[in] | dbout | Output Db structure |
[out] | pot_ext | Pot_Ext structure |
|
static |
|
static |
|
static |
Establish kriging system
[out] | pot_ext | Pot_Ext structure |
[out] | number | Matrix dimension |
|
static |
Calculate the external drift contribution
|
static |
|
static |
Establish the data vector
[in] | pot_env | Pot_Env structure |
[out] | zval | Data vector |
|
static |
|
static |
|
static |
Translate potential into layer value or center it
[in] | pot_env | Pot_Env structure |
[in] | isimu | Rank of the simulation |
[in] | potval | Array of potential values at different layers |
[in] | result | Resulting value (in potential scale) On output, Resulting value in layer scale |
|
static |
|
static |
Manage the Pot_Env structure
[in,out] | pot_env | Pot_env structure |
[in] | flag_pot | True if the potential must be calculated |
[in] | flag_grad | True if the gradients must be calculated |
[in] | flag_trans | True if the estimation result must be translated into layer number |
[in] | opt_part | Option to exhibit only a part of estimation:
|
[in] | verbose | Verbose flag |
bool st_potenv_valid | ( | Pot_Env * | pot_env, |
Pot_Ext * | pot_ext, | ||
Db * | dbiso, | ||
Db * | dbgrd, | ||
Db * | dbtgt, | ||
DbGrid * | dbout, | ||
Model * | model, | ||
ANeigh * | neigh | ||
) |
|
static |
Manage the Pot_Ext structure
[in] | mode | 1 for allocation; 0 for save; -1 for deallocation |
[in] | pot_ext | Pot_Ext structure to be managed |
[in] | nring | Number of rings used for Ext. Drift calculations |
[in] | range | Range of the structure |
[in] | dbout | Output Db structure |
|
static |
Print the estimation at a target sample
[in] | pot_env | Pot_env structure |
[in] | isimu | Rank of the simulation (or -1) |
[in] | result | Array of results |
[in] | tgtval | Value of the tangent (or TEST) |
|
static |
Print the type of information for the Potential covariance
[in] | rank | Rank of the point |
[in] | type | Type of the first point 1 for gradient; 2 for tangent; 3 for isopotential |
|
static |
Blank out part the R.H.S. according to 'flag.part'
[in] | pot_env | Pot_Env structure |
[in,out] | rhs | Array for the R.H.S. |
|
static |
|
static |
Calculate the conditional simulation at target samples
[in] | pot_env | Pot_Env structure |
[in] | pot_ext | Pot_Ext structure |
[in] | dist_tempere | Distance for tempering simulations (or TEST) |
[in] | flag_trans | True if the estimation result must be translated into layer number |
[in] | nbsimu | Number of simulation |
[in] | dbiso | Iso-potential Db structure |
[in] | dbgrd | Gradient Db structure |
[in] | dbtgt | Tangent Db structure (optional) |
[in] | dbout | Output Db structure |
[in] | model | Model structure |
[in] | refpot | Potential at Reference point |
[in] | potsim | Potential simulated values at iso-potential samples |
[in] | zdual | Dual estimated vector (Dimension: nequa) |
[in] | zduals | Dual simulated vector (Dimension: nequa * nbsimu) |
[in] | rhs | R.H.S. vector (Dimension: nequa * 4) |
|
static |
Amortize the conditional simulations
[in] | dbout | Output Db structure |
[in] | iech | Rank of the sample |
[in] | dist_tempere | Distance for tempering simulations (or TEST) |
[in] | reskrige | Kriging result |
[in] | result | Conditional Simulation result On output, Conditional Simulation tempered result |
|
static |
Make the final checks and define the addresses
[in] | model | Model structure |
[in,out] | pot_env | The Pot_Env structure |
|
static |
|
static |
Load the information linked to the Iso_potentials
[in] | dbiso | Input Db structure for Iso-Potential |
[in,out] | pot_env | The Pot_Env structure |
|
static |
|
static |
Load the information linked to the Tangents
[in] | dbtgt | Input Db structure |
[in,out] | pot_env | The Pot_Env structure |
|
static |
Calculate the cross-validation at the iso-potential samples
[in] | pot_env | Pot_Env structure |
[in] | pot_ext | Pot_Ext structure |
[in] | dbiso | Iso-potential Db structure |
[in] | dbgrd | Gradient Db structure |
[in] | dbtgt | Tangent Db structure (optional) |
[in] | model | Model structure |
[in] | lhs | Inverted Kriging system |
[in] | flag_dist_conv | Flag for converting into distance |
[in] | zval | Data vector |
[in] | lhs_orig | Copy of the Initial LHS |
[in] | rhs | Right-hand side |
[in] | zdual | Dual vector (Dimension: nequa) |
|
static |
|
static |
|
static |