1.4.0
CCC
 
krige.cpp File Reference
#include "geoslib_f.h"
#include "geoslib_old_f.h"
#include "geoslib_f_private.h"
#include "geoslib_define.h"
#include "Enum/ECalcMember.hpp"
#include "Db/Db.hpp"
#include "Db/DbGrid.hpp"
#include "Model/Model.hpp"
#include "Model/CovInternal.hpp"
#include "Neigh/NeighMoving.hpp"
#include "Neigh/NeighImage.hpp"
#include "Neigh/NeighUnique.hpp"
#include "Neigh/ANeigh.hpp"
#include "Anamorphosis/AnamDiscreteIR.hpp"
#include "Anamorphosis/AnamHermite.hpp"
#include "Basic/String.hpp"
#include "Basic/NamingConvention.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/Law.hpp"
#include "Basic/File.hpp"
#include "Basic/OptDbg.hpp"
#include "Covariances/CovContext.hpp"
#include "Drifts/DriftList.hpp"
#include "Estimation/KrigingSystem.hpp"
#include "Matrix/MatrixFactory.hpp"
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <limits.h>

Classes

struct  Disc_Structure
 

Functions

static double * st_core (int nli, int nco)
 
static int * st_icore (int nli, int nco)
 
static int * st_relative_position_array (int mode, int neq, int *rel_arg)
 
static void st_global_init (Db *dbin, Db *dbout)
 
static double st_get_idim (int loc_rank, int idim)
 
int is_flag_data_disc_defined (void)
 ‍****************************************************************************‍/ *! More...
 
void set_DBIN (Db *dbin)
 
void set_DBOUT (Db *dbout)
 
static double st_get_ivar (int rank, int ivar)
 ‍****************************************************************************‍/ *! More...
 
static double st_get_verr (int rank, int ivar)
 
static int st_check_environment (int flag_in, int flag_out, Model *model)
 
static int st_model_manage (int mode, Model *model)
 
static int st_krige_manage_basic (int mode, int nech, int nmax, int nvar, int nfeq)
 
static int st_get_nmax (ANeigh *neigh)
 
static int st_krige_manage (int mode, int nvar, Model *model, ANeigh *neigh)
 
static int st_block_discretize_alloc (int ndim, const VectorInt &ndiscs)
 
static void st_data_discretize_alloc (int ndim)
 
static void st_block_discretize (int mode, int flag_rand, int iech)
 
int krige_koption_manage (int mode, int flag_check, const EKrigOpt &calcul, int flag_rand, const VectorInt &ndiscs)
 
void krige_lhs_print (int nech, int neq, int nred, const int *flag, const double *lhs)
 
void krige_rhs_print (int nvar, int nech, int neq, int nred, const int *flag, double *rhs)
 
void krige_dual_print (int nech, int neq, int nred, const int *flag, double *dual)
 
static void krige_wgt_print (int status, int nvar, int nvar_m, int nfeq, const VectorInt &nbgh_ranks, int nred, int icase, const int *flag, const double *wgt)
 
static void st_result_kriging_print (int flag_xvalid, int nvar, int status)
 
int _krigsim (Db *dbin, Db *dbout, const Model *model, ANeigh *neigh, bool flag_bayes, const VectorDouble &dmean, const MatrixSquareSymmetric &dcov, int icase, int nbsimu, bool flag_dgm)
 
int global_transitive (DbGrid *dbgrid, Model *model, int flag_verbose, int flag_regular, int ndisc, double *abundance, double *sse, double *cvtrans)
 
static int st_get_limits (DbGrid *db, double top, double bot, int *ideb, int *ifin)
 
static int st_get_neigh (int ideb, int ifin, int neigh_radius, int *status, int *nbefore, int *nafter)
 
static double st_cov_exp (int dist, const double *cov, int cov_radius, int flag_sym)
 
static void st_lhs_exp (double *covdd, int cov_radius, int flag_sym, int nfeq, int nbefore, int nafter, int neq)
 
static void st_rhs_exp (double *covd0, int cov_radius, int flag_sym, int nfeq, int nbefore, int nafter, int neq)
 
static double st_estim_exp (Db *db, const double *wgt, int nbefore, int nafter)
 
int anakexp_f (DbGrid *db, double *covdd, double *covd0, double top, double bot, int cov_radius, int neigh_radius, int flag_sym, int nfeq)
 
static void st_calculate_covres (DbGrid *db, Model *model, const double *cov_ref, int cov_radius, int flag_sym, const int cov_ss[3], const int cov_nn[3], double *cov_res)
 
static void st_calculate_covtot (DbGrid *db, int ix0, int iy0, int flag_sym, const int cov_ss[3], const int cov_nn[3], int *num_tot, double *cov_tot)
 
static VectorInt st_neigh_find (DbGrid *db, int ix0, int iy0, int iz0, const int nei_ss[3], const int nei_nn[3], int *nei_cur)
 
static int st_neigh_diff (const int nei_ss[3], const int nei_nn[3], int *nei_ref, const int *nei_cur)
 
static void st_lhs_exp_3D (int nech, int nfeq, const int nei_ss[3], const int nei_nn[3], const int cov_ss[3], const int cov_nn[3], const int *nei_cur, const double *cov_tot, double nugget)
 
static void st_rhs_exp_3D (int nech, int nfeq, const int nei_ss[3], const int nei_nn[3], const int cov_ss[3], const int cov_nn[3], const int *nei_cur, const double *cov_res)
 
static double st_estim_exp_3D (Db *db, const int nei_ss[3], const int nei_nn[3], int *nei_cur, const double *weight)
 
static void st_vario_dump (FILE *file, int ix0, int iy0, const int cov_ss[3], const int cov_nn[3], const int *num_tot, const double *cov_tot)
 
int anakexp_3D (DbGrid *db, double *cov_ref, int cov_radius, int neigh_ver, int neigh_hor, int flag_sym, Model *model, double nugget, int nfeq, int dbg_ix, int dbg_iy)
 
int bayes_simulate (Model *model, int nbsimu, const VectorDouble &rmean, const VectorDouble &rcov, VectorDouble &smean)
 
int krigsum (Db *dbin, Db *dbout, Model *model, ANeigh *neigh, bool flag_positive, const NamingConvention &namconv)
 
static VectorInt st_ranks_other (int nech, const VectorInt &ranks1, const VectorInt &ranks2)
 
static int st_sampling_krige_data (Db *db, Model *model, double beta, VectorInt &ranks1, VectorInt &ranks2, VectorInt &rother, int *ntot_arg, int *nutil_arg, VectorInt &rutil, double **tutil_arg, double **invsig_arg)
 
int st_krige_data (Db *db, Model *model, double beta, VectorInt &ranks1, VectorInt &ranks2, VectorInt &rother, int flag_abs, double *data_est, double *data_var)
 
int st_crit_global (Db *db, Model *model, VectorInt &ranks1, VectorInt &rother, double *crit)
 
int sampling_f (Db *db, Model *model, double beta, int method1, int nsize1_max, VectorInt &ranks1, int method2, int nsize2_max, VectorInt &ranks2, int verbose)
 
int krigsampling_f (Db *dbin, Db *dbout, Model *model, double beta, VectorInt &ranks1, VectorInt &ranks2, bool flag_std, int verbose)
 
static void st_declustering_stats (int mode, int method, Db *db, int iptr)
 
static void st_declustering_truncate_and_rescale (Db *db, int iptr)
 
static int st_declustering_1 (Db *db, int iptr, const VectorDouble &radius)
 
static int st_declustering_2 (Db *db, Model *model, ANeigh *neigh, int iptr)
 
static int st_declustering_3 (Db *db, Db *dbgrid, Model *model, ANeigh *neigh, const VectorInt &ndiscs, int iptr)
 
int declustering (Db *dbin, Model *model, int method, ANeigh *neigh, DbGrid *dbgrid, const VectorDouble &radius, const VectorInt &ndiscs, int flag_sel, bool verbose)
 
static double * st_calcul_covmat (const char *title, Db *db1, int test_def1, Db *db2, int test_def2, Model *model)
 
static double * st_calcul_drfmat (const char *title, Db *db1, int test_def1, Model *model)
 
static double * st_calcul_distmat (const char *title, Db *db1, int test_def1, Db *db2, int test_def2, double power)
 
static double * st_calcul_product (const char *title, int n1, int ns, const double *covss, const double *distgen)
 
static double * st_inhomogeneous_covpp (Db *dbdat, Db *dbsrc, Model *model_dat, const double *distps, const double *prodps)
 
static double * st_inhomogeneous_covgp (Db *dbdat, Db *dbsrc, Db *dbout, int flag_source, Model *model_dat, const double *distps, const double *prodps, const double *prodgs)
 
static VectorDouble st_inhomogeneous_covgg (Db *dbsrc, Db *dbout, int flag_source, Model *model_dat, const double *distgs, const double *prodgs)
 
static int st_drift_prepar (int np, int nbfl, const double *covpp, const double *drftab, double **yloc, double **zloc)
 
static void st_drift_update (int np, int nbfl, const double *covgp, const double *driftg, const double *ymat, double *zmat, double *maux, double *lambda, double *mu)
 
int inhomogeneous_kriging (Db *dbdat, Db *dbsrc, Db *dbout, double power, int flag_source, Model *model_dat, Model *model_src)
 
void _image_smoother (DbGrid *dbgrid, const NeighImage *neigh, int type, double range, int iptr0)
 

Variables

static double * covaux_global
 
static double * d1_1_global
 
static double * d1_2_global
 
static double * var0_global
 
static VectorDouble d1_global
 
static VectorDouble d1_t_global
 
static double * lhs_global
 
static double * rhs_global
 
static double * wgt_global
 
static double * zam1_global
 
static int * flag_global
 
static int KRIGE_INIT = 0
 
static int MODEL_INIT = 0
 
static int IECH_OUT = -1
 
static int FLAG_COLK
 
static int FLAG_SIMU
 
static int FLAG_EST
 
static int FLAG_STD
 
static int FLAG_VARZ
 
static int FLAG_PROF
 
static int IPTR_EST
 
static int IPTR_STD
 
static int IPTR_VARZ
 
static int IPTR_NBGH
 
static int * RANK_COLCOK
 
static DbDBIN
 
static DbDBOUT
 
static KoptionKOPTION
 
static int INH_FLAG_VERBOSE = 0
 
static int INH_FLAG_LIMIT = 1
 
static char string [100]
 
static CovInternal COVINT
 

Function Documentation

◆ _image_smoother()

void _image_smoother ( DbGrid dbgrid,
const NeighImage neigh,
int  type,
double  range,
int  iptr0 
)

Smooth a regular grid

Parameters
[in]dbgridinput and output Db grid structure
[in]neighNeigh structure
[in]type1 for Uniform; 2 for Gaussian
[in]rangeRange (used for Gaussian only)
[in]iptr0Storage address
Remarks
Limited to the monovariate case

◆ _krigsim()

int _krigsim ( Db dbin,
Db dbout,
const Model model,
ANeigh neigh,
bool  flag_bayes,
const VectorDouble dmean,
const MatrixSquareSymmetric dcov,
int  icase,
int  nbsimu,
bool  flag_dgm 
)

Conditioning Kriging

Returns
Error return code
Parameters
[in]dbininput Db structure
[in]dboutoutput Db structure
[in]modelModel structure
[in]neighANeigh structure
[in]flag_bayes1 if Bayes option is switched ON
[in]dmeanArray giving the prior means for the drift terms
[in]dcovArray containing the prior covariance matrix for the drift terms
[in]icaseCase for PGS and GRF (or -1)
[in]nbsimuNumber of simulations
[in]flag_dgm1 if the DGM version of kriging should be used
Remarks
: The model contains an anamorphosis with a change of support
: coefficient as soon as flag_dgm is TRUE

◆ anakexp_3D()

int anakexp_3D ( DbGrid db,
double *  cov_ref,
int  cov_radius,
int  neigh_ver,
int  neigh_hor,
int  flag_sym,
Model model,
double  nugget,
int  nfeq,
int  dbg_ix,
int  dbg_iy 
)

Factorial Kriging analysis on a grid file using discretized covariances for the target variable. The discretized covariance of the total variable is calculated on the fly

Returns
Error return code
Parameters
[in]dbinput Db structure
[in]cov_refArray of discretized covariance for target variable
[in]cov_radiusRadius of the covariance array
[in]neigh_verRadius of the Neighborhood along Vertical
[in]neigh_horRadius of the Neighborhood along Horizontal
[in]flag_sym1 for symmetrized covariance
[in]modelModel structure (only used for horizontal)
[in]nuggetAdditional Nugget Effect component
[in]nfeq0 or 1 drift function(s)
[in]dbg_ixRank of the trace along X for variogram debug
[in]dbg_iyRank of the trace along Y for variogram debug
Remarks
The discretized covariance of the target variable is provided
in 1-D along the vertical. Its extension to the space dimension
is performed using the theoretical factorized model
If dbg_ix < -1 || dbg_iy < -1, no variogram debug file is created

◆ anakexp_f()

int anakexp_f ( DbGrid db,
double *  covdd,
double *  covd0,
double  top,
double  bot,
int  cov_radius,
int  neigh_radius,
int  flag_sym,
int  nfeq 
)

Factorial Kriging analysis on a 1-D grid file using discretized covariances for total and partial variables

Returns
Error return code
Parameters
[in]dbinput Db structure
[in]covddArray of discretized cov. for total variable
[in]covd0Array of discretized cov. for partial variable
[in]topElevation of the Top variable
[in]botElevation of the bottom variable
[in]cov_radiusRadius of the Covariance arrays
[in]neigh_radiusRadius of the Neighborhood
[in]flag_sym1 for symmetrized covariance
[in]nfeq0 or 1 drift function(s)

◆ bayes_simulate()

int bayes_simulate ( Model model,
int  nbsimu,
const VectorDouble rmean,
const VectorDouble rcov,
VectorDouble smean 
)

Simulate the drift coefficients from the posterior distributions

Returns
Error returned code
Parameters
[in]modelModel structure
[in]nbsimuNumber of simulation (0 for kriging)
[in]rmeanArray giving the posterior means for the drift terms
[in]rcovArray containing the posterior covariance matrix for the drift terms
[out]smeanArray for simulated posterior mean for the drift means

◆ declustering()

int declustering ( Db dbin,
Model model,
int  method,
ANeigh neigh,
DbGrid dbgrid,
const VectorDouble radius,
const VectorInt ndiscs,
int  flag_sel,
bool  verbose 
)

Perform the Declustering task

Returns
Error return code
Parameters
[in]dbininput Db structure
[in]modelModel structure
[in]methodMethod for declustering
[in]neighANeigh structure
[in]dbgridGrid auxiliary Db structure
[in]radiusArray of neighborhood radius
[in]ndiscsArray of discretization
[in]flag_sel1 to mask off samples with zero weight
[in]verboseVerbose option

◆ global_transitive()

int global_transitive ( DbGrid dbgrid,
Model model,
int  flag_verbose,
int  flag_regular,
int  ndisc,
double *  abundance,
double *  sse,
double *  cvtrans 
)

Estimation of the variance by transitive method

Returns
Error return code
Parameters
[in]dbgridDb structure containing the dicretization grid
[in]modelModel structure
[in]flag_verbose1 for a verbose output
[in]flag_regular1 for regular; 0 for stratified
[in]ndiscNumber of Discretization steps
[out]abundanceGlobal estimated abundance
[out]sseGlobal standard deviation
[out]cvtransCV transitive

◆ inhomogeneous_kriging()

int inhomogeneous_kriging ( Db dbdat,
Db dbsrc,
Db dbout,
double  power,
int  flag_source,
Model model_dat,
Model model_src 
)

Inhomogeneous Kriging with Sources

Returns
Error return code
Parameters
[in]dbdatDb structure containing Data
[in]dbsrcDb structure containing Sources
[in]dboutOutput Db structure
[in]powerPower of the Distance decay
[in]flag_sourceIf the result is the source, rather than diffusion
[in]model_datModel structure for the data
[in]model_srcModel structure for the sources

◆ is_flag_data_disc_defined()

int is_flag_data_disc_defined ( void  )

‍****************************************************************************‍/ *!

‍****************************************************************************‍/ *!

◆ krige_dual_print()

void krige_dual_print ( int  nech,
int  neq,
int  nred,
const int *  flag,
double *  dual 
)

Print the Dual matrix

Parameters
[in]nechNumber of active points (optional)
[in]neqNumber of equations
[in]nredReduced number of equations
[in]flagFlag array (optional)
[in]dualKriging Dual matrix

◆ krige_koption_manage()

int krige_koption_manage ( int  mode,
int  flag_check,
const EKrigOpt &  calcul,
int  flag_rand,
const VectorInt ndiscs 
)

Management of Kriging option

Returns
Error return code
Parameters
[in]mode1 for allocation; -1 for deallocation
[in]flag_check1 if the file should be checked
[in]calculType of calculation (EKrigOpt)
[in]flag_rand0 if the second discretization is regular 1 if the second point must be randomized
[in]ndiscsDiscretization parameters (or NULL)
Remarks
This function manages the global structure KOPTION

◆ krige_lhs_print()

void krige_lhs_print ( int  nech,
int  neq,
int  nred,
const int *  flag,
const double *  lhs 
)

Print the L.H.S. matrix

Parameters
[in]nechNumber of active points (optional)
[in]neqNumber of equations
[in]nredReduced number of equations
[in]flagFlag array (optional)
[in]lhsKriging L.H.S

◆ krige_rhs_print()

void krige_rhs_print ( int  nvar,
int  nech,
int  neq,
int  nred,
const int *  flag,
double *  rhs 
)

Print the R.H.S. matrix

Parameters
[in]nvarNumber of variables
[in]nechNumber of active points (optional)
[in]neqNumber of equations
[in]nredReduced number of equations
[in]flagFlag array (optional)
[in]rhsKriging R.H.S. matrix

◆ krige_wgt_print()

static void krige_wgt_print ( int  status,
int  nvar,
int  nvar_m,
int  nfeq,
const VectorInt nbgh_ranks,
int  nred,
int  icase,
const int *  flag,
const double *  wgt 
)
static

Print the kriging weights

Parameters
[in]statusKriging error status
[in]nvarNumber of variables (output)
[in]nvar_mNumber of variables in the Model
[in]nfeqNumber of drift equations
[in]nbgh_ranksVector of selected samples
[in]nredReduced number of equations
[in]icaseRank of the PGS or GRF
[in]flagFlag array
[in]wgtArray of Kriging weights
Remarks
In the case of simulations (icase>=0), the data vector is not
printed as it changes for every sample, per simulation

◆ krigsampling_f()

int krigsampling_f ( Db dbin,
Db dbout,
Model model,
double  beta,
VectorInt ranks1,
VectorInt ranks2,
bool  flag_std,
int  verbose 
)

Perform the Kriging procedure using the parcimonious search within the whole input data set

Returns
Error retun code
Parameters
[in]dbinInput Db structure
[in]dboutOutput Db structure
[in]modelModel structure
[in]betaThresholding value
[in]ranks1Ranks of exact pivots
[in]ranks2Ranks of ACP pivots
[in]flag_stdOption for storing the standard deviation
[in]verboseVerbose flag

◆ krigsum()

int krigsum ( Db dbin,
Db dbout,
Model model,
ANeigh neigh,
bool  flag_positive,
const NamingConvention namconv 
)

Punctual Multivariate Kriging under a constraint

Returns
Error return code
Parameters
[in]dbininput Db structure
[in]dboutoutput Db structure
[in]modelModel structure (univariate)
[in]neighANeigh structure
[in]flag_positive1 for a positive constraints
[in]namconvNaming convention
Remarks
All the variables are estimated using the same model
In this procedure, we assume that:
- the problem is multivariate ("z" variables)
- the constraints is stored in "sum" (only used in dbout)

◆ sampling_f()

int sampling_f ( Db db,
Model model,
double  beta,
int  method1,
int  nsize1_max,
VectorInt ranks1,
int  method2,
int  nsize2_max,
VectorInt ranks2,
int  verbose 
)

Optimize the sampling design

Returns
Error retun code
Parameters
[in]dbDb structure
[in]modelModel structure
[in]betaThresholding value
[in]method1Criterion for choosing exact pivots 1 : Local evaluation 2 : Global evaluation
[in]nsize1_maxMaximum number of exact pivots
[in]ranks1Ranks of exact pivots
[in]method2Criterion for choosing ACP pivots 1 : Local evaluation 2 : Global evaluation
[in]nsize2_maxMaximum number of ACP pivots
[in]ranks2Ranks of ACP pivots
[in]verbose1 for a verbose output

◆ set_DBIN()

void set_DBIN ( Db dbin)

◆ set_DBOUT()

void set_DBOUT ( Db dbout)

◆ st_block_discretize()

static void st_block_discretize ( int  mode,
int  flag_rand,
int  iech 
)
static

Discretize a block

Parameters
[in]mode0 if the block extension is read from grid 1 if the block extension is read from variable
[in]flag_rand0 if the second discretization is regular 1 if the second point must be randomized
[in]iechrank of the variable (used when mode=1)

◆ st_block_discretize_alloc()

static int st_block_discretize_alloc ( int  ndim,
const VectorInt ndiscs 
)
static

Allocate the Target discretization

Parameters
[in]ndimSpace dimension
[in]ndiscsDiscretization parameters (or NULL)

◆ st_calcul_covmat()

static double* st_calcul_covmat ( const char *  title,
Db db1,
int  test_def1,
Db db2,
int  test_def2,
Model model 
)
static

Establish the covariance matrix between two Dbs

Returns
Covariance matrix (Dim: n1 * n2)
Parameters
[in]titleTitle of the optional printout
[in]db1First Db structure
[in]test_def11 if the first variable (ELoc::Z) must be checked
[in]db2Second Db structure
[in]test_def21 if the second variable (ELoc::Z) must be checked
[in]modelModel structure
Remarks
The returned argument must be freed by the calling function

◆ st_calcul_distmat()

static double* st_calcul_distmat ( const char *  title,
Db db1,
int  test_def1,
Db db2,
int  test_def2,
double  power 
)
static

Establish the distance matrix between two Dbs

Returns
Covariance matrix
Parameters
[in]titleTitle of the optional printout
[in]db1First Db structure
[in]test_def11 if the first variable (ELoc::Z) must be checked
[in]db2Second Db structure (sources)
[in]test_def21 if the second variable (ELoc::Z) must be checked
[in]powerPower of the Distance decay
Remarks
The returned argument must be freed by the calling function

◆ st_calcul_drfmat()

static double* st_calcul_drfmat ( const char *  title,
Db db1,
int  test_def1,
Model model 
)
static

Establish the drift matrix for a given Db

Returns
Drift matrix (Dim: n1 * nbfl)
Parameters
[in]titleTitle of the optionla printout
[in]db1First Db structure
[in]test_def11 if the first variable (ELoc::Z) must be checked
[in]modelModel structure
Remarks
The returned argument must be freed by the calling function

◆ st_calcul_product()

static double* st_calcul_product ( const char *  title,
int  n1,
int  ns,
const double *  covss,
const double *  distgen 
)
static

Operate the product of the Distance by the Source covariance matrix

Returns
Product matrix
Parameters
[in]titleTitle of the optionla printout
[in]n1Number of Data
[in]nsNumber of Sources
[in]covssCovariance Matrix between Sources (Dim: ns*ns)
[in]distgenDistance matrix
Remarks
The returned argument must be freed by the calling function

◆ st_calculate_covres()

static void st_calculate_covres ( DbGrid db,
Model model,
const double *  cov_ref,
int  cov_radius,
int  flag_sym,
const int  cov_ss[3],
const int  cov_nn[3],
double *  cov_res 
)
static

Calculate the experimental covariance of the residual variable defined on the grid

Parameters
[in]dbinput Db structure
[in]modelModel describing the horizontal structure
[in]cov_refArray of discretized covariance for target variable
[in]cov_radiusRadius of the covariance array
[in]flag_sym1 for symmetrized covariance
[in]cov_ssArray of dimensions of the Covariance array
[in]cov_nnArray of radius of the Covariance array
[out]cov_resArray containing the covariance of the residual variable

◆ st_calculate_covtot()

static void st_calculate_covtot ( DbGrid db,
int  ix0,
int  iy0,
int  flag_sym,
const int  cov_ss[3],
const int  cov_nn[3],
int *  num_tot,
double *  cov_tot 
)
static

Calculate the experimental covariance of the total variable defined on the grid

Parameters
[in]dbinput Db structure
[in]ix0index of the grid index along X
[in]iy0index of the grid index along Y
[in]flag_sym1 for symmetrized covariance
[in]cov_ssArray of dimensions of the Covariance array
[in]cov_nnArray of radius of the Covariance array
[out]num_totArray containing the numb er of pairs
[out]cov_totArray containing the covariance of the total variable

◆ st_check_environment()

static int st_check_environment ( int  flag_in,
int  flag_out,
Model model 
)
static

Checks the kriging environment

Returns
Error return code
Parameters
[in]flag_in1 if the Input Db is used
[in]flag_out1 if the Output Db is used
[in]modelModel structure (optional)
Remarks
The address of the argument 'neigh' is memorized in a local
static variable

◆ st_core()

static double* st_core ( int  nli,
int  nco 
)
static

Management of internal array (double)

Returns
Pointer to the newly allocated array
Parameters
[in]nliNumber of lines
[in]ncoNumber of columns

◆ st_cov_exp()

static double st_cov_exp ( int  dist,
const double *  cov,
int  cov_radius,
int  flag_sym 
)
static

Calculate the discretized covariance

Parameters
[in]distInteger distance
[in]covArray of discretized covariances
[in]cov_radiusRadius of the covariance array
[in]flag_sym1 for symmetrized covariance

◆ st_crit_global()

int st_crit_global ( Db db,
Model model,
VectorInt ranks1,
VectorInt rother,
double *  crit 
)

Evaluate the improvement in adding a new pivot on the global score

Returns
Error retun code
Parameters
[in]dbDb structure
[in]modelModel structure
[in]ranks1Ranks of exact pivots
[in]rotherRanks of the idle samples
[out]critArray of criterion

◆ st_data_discretize_alloc()

static void st_data_discretize_alloc ( int  ndim)
static

Allocate the Data discretization

Parameters
[in]ndimSpace dimension

◆ st_declustering_1()

static int st_declustering_1 ( Db db,
int  iptr,
const VectorDouble radius 
)
static

Perform the Declustering task (Number of samples within an ellipse)

Returns
Error return code
Parameters
[in]dbinput Db structure
[in]iptrRank of the declustering weight
[in]radiusArray of neighborhood radius

◆ st_declustering_2()

static int st_declustering_2 ( Db db,
Model model,
ANeigh neigh,
int  iptr 
)
static

Perform the Declustering task as weight of the Mean Kriging (Unique Neigh)

Returns
Error return code
Parameters
[in]dbinput Db structure
[in]modelModel structure
[in]neighANeigh structure (should be Unique)
[in]iptrRank of the declustering weight

◆ st_declustering_3()

static int st_declustering_3 ( Db db,
Db dbgrid,
Model model,
ANeigh neigh,
const VectorInt ndiscs,
int  iptr 
)
static

Perform the Declustering task as the sum of the weight for Kriging the Cells of a grid

Returns
Error return code
Parameters
[in]dbinput Db structure
[in]dbgridoutput Db structure
[in]modelModel structure
[in]neighANeigh structure
[in]ndiscsArray of discretization counts
[in]iptrRank of the declustering weight

◆ st_declustering_stats()

static void st_declustering_stats ( int  mode,
int  method,
Db db,
int  iptr 
)
static

Display the statistics of the target variable before or after the Declustering

Parameters
[in]mode0 before the declustering; 1 after
[in]methodMethod for declustering
[in]dbinput Db structure
[in]iptrRank of the weighting variable

◆ st_declustering_truncate_and_rescale()

static void st_declustering_truncate_and_rescale ( Db db,
int  iptr 
)
static

Truncate the negative weights and scale the remaining ones

Parameters
[in]dbDb structure
[in]iptrRank of the Weight variable

◆ st_drift_prepar()

static int st_drift_prepar ( int  np,
int  nbfl,
const double *  covpp,
const double *  drftab,
double **  yloc,
double **  zloc 
)
static

Calculate auxiliary arrays when drift is preset

Returns
Error return code
Parameters
[in]npNumber of data
[in]nbflNumber of drift functions
[in]covppInverse Covariance between Data-Data
[in]drftabDrift matrix at Data
[out]ylocArray: t(F) %*% C^-1
[out]zlocArray: (t(F) %*% C^-1 %*% F)^-1
Remarks
The returned arrays 'yloc' and 'zloc' must be freed by the
calling function

◆ st_drift_update()

static void st_drift_update ( int  np,
int  nbfl,
const double *  covgp,
const double *  driftg,
const double *  ymat,
double *  zmat,
double *  maux,
double *  lambda,
double *  mu 
)
static

Update the weight vector

Parameters
[in]npNumber of data
[in]nbflNumber of drift functions
[in]covgpCovariance matrix between Data and Target
[in]driftgDrift matrix at Target
[in]ymatAuxiliary array
[in]zmatAuxiliary array
[in]mauxAuxiliary array (Dimension: nbfl)
[out]lambdaVector of weights
[out]muVector of Lagrange parameters

◆ st_estim_exp()

static double st_estim_exp ( Db db,
const double *  wgt,
int  nbefore,
int  nafter 
)
static

Perform the estimation for the Factorial Kriging Analysis in the case of the discretized covariances

Parameters
[in]dbDb structure
[in]wgtArray containing the kriging weights
[in]nbeforeNumber of samples in neighborhood before target
[in]nafterNumber of samples in neighborhood after target

◆ st_estim_exp_3D()

static double st_estim_exp_3D ( Db db,
const int  nei_ss[3],
const int  nei_nn[3],
int *  nei_cur,
const double *  weight 
)
static

Evaluate the Factorial Kriging estimate

Returns
The estimation result
Parameters
[in]dbinput Db structure
[in]nei_ssArray of dimensions of the Neighborhood
[in]nei_nnArray of radius of the Neighborhood
[in]nei_curArray containing the current neighborhood
[in]weightArray of Kriging weights

◆ st_get_idim()

static double st_get_idim ( int  loc_rank,
int  idim 
)
static

Returns the coordinate of the data (at rank if rank >= 0) or of the target (at IECH_OUT if rank < 0)

Parameters
[in]loc_rankRank of the sample
[in]idimRank of the coordinate

◆ st_get_ivar()

static double st_get_ivar ( int  rank,
int  ivar 
)
static

‍****************************************************************************‍/ *!

Returns the value of the variable (at rank if rank >= 0) or of the target (at IECH_OUT if rank < 0)

Parameters
[in]rankRank of the sample
[in]ivarRank of the variable
Remarks
In case of simulation, the variable of the first simulation
is systematically returned. This has no influence on the rest
of the calculations

◆ st_get_limits()

static int st_get_limits ( DbGrid db,
double  top,
double  bot,
int *  ideb,
int *  ifin 
)
static

Returns the limits of the area of interest

Returns
Error returned code
Parameters
[in]dbinput Db structure
[in]topElevation of the Top variable
[in]botElevation of the bottom variable
[out]idebIndex of the starting sample
[out]ifinIndex of the ending sample

◆ st_get_neigh()

static int st_get_neigh ( int  ideb,
int  ifin,
int  neigh_radius,
int *  status,
int *  nbefore,
int *  nafter 
)
static

Definition of the neighborhood

Returns
Error return code: 1 if the target does not belong to the
area of interest
Parameters
[in]idebIndex of the starting sample
[in]ifinIndex of the ending sample
[in]neigh_radiusRadius of the Neighborhood
[out]statusNeighborhood error status
[out]nbeforeNumber of samples in neighborhood before target
[out]nafterNumber of samples in neighborhood after target

◆ st_get_nmax()

static int st_get_nmax ( ANeigh neigh)
static

Returns the maximum number of points per neighborhood

Returns
Maximum number of points per neighborhood
Parameters
[in]neighANeigh structure

◆ st_get_verr()

static double st_get_verr ( int  rank,
int  ivar 
)
static

Returns the value of the measurement error (at rank if rank >= 0) or of the target (at IECH_OUT if rank < 0)

Parameters
[in]rankRank of the sample
[in]ivarRank of the variable

◆ st_global_init()

static void st_global_init ( Db dbin,
Db dbout 
)
static

Initialize the static global variables

Parameters
[in]dbininput Db structure
[in]dboutoutput Db structure

◆ st_icore()

static int* st_icore ( int  nli,
int  nco 
)
static

Management of internal array (integer)

Returns
Pointer to the newly allocated array
Parameters
[in]nliNumber of lines
[in]ncoNumber of columns

◆ st_inhomogeneous_covgg()

static VectorDouble st_inhomogeneous_covgg ( Db dbsrc,
Db dbout,
int  flag_source,
Model model_dat,
const double *  distgs,
const double *  prodgs 
)
static

Establish the covariance vector at target

Returns
Covariance vector
Parameters
[in]dbsrcDb structure containing Sources
[in]dboutDb structure for target
[in]flag_sourceIf the result is the source, rather than diffusion
[in]model_datModel structure for the data
[in]distgsDistance matrix between Target and Sources
[in]prodgsProduct of DistGS by CovSS
Remarks
The returned argument must be freed by the calling function

◆ st_inhomogeneous_covgp()

static double* st_inhomogeneous_covgp ( Db dbdat,
Db dbsrc,
Db dbout,
int  flag_source,
Model model_dat,
const double *  distps,
const double *  prodps,
const double *  prodgs 
)
static

Establish the R.H.S. for Inhomogeneous Kriging

Returns
Covariance matrix
Parameters
[in]dbdatDb structure containing Data
[in]dbsrcDb structure containing Sources
[in]dboutDb structure containing Targets
[in]flag_sourceIf the result is the source, rather than diffusion
[in]model_datModel structure for the data
[in]distpsDistance matrix between Data and Sources
[in]prodpsProduct of DistPS by CovSS
[in]prodgsProduct of DistGS by CovSS
Remarks
: When used with flag_source=TRUE, 'dbsrc' and 'dbout' coincide

◆ st_inhomogeneous_covpp()

static double* st_inhomogeneous_covpp ( Db dbdat,
Db dbsrc,
Model model_dat,
const double *  distps,
const double *  prodps 
)
static

Establish the L.H.S. for Inhomogeonous Kriging

Returns
Covariance matrix
Parameters
[in]dbdatDb structure containing Data
[in]dbsrcDb structure containing Sources
[in]model_datModel structure for the data
[in]distpsDistance matrix between Data and Sources
[in]prodpsProduct of DistPS by CovSS

◆ st_krige_data()

int st_krige_data ( Db db,
Model model,
double  beta,
VectorInt ranks1,
VectorInt ranks2,
VectorInt rother,
int  flag_abs,
double *  data_est,
double *  data_var 
)

Perform the estimation at the data points

Returns
Error return code
Parameters
[in]dbDb structure
[in]modelModel structure
[in]betaThresholding value
[in]ranks1Ranks of exact pivots
[in]ranks2Ranks of ACP pivots
[in]rotherRanks of the idle samples
[in]flag_abs1 Modify 'daata_est' to store the estimation error
[out]data_estArray of estimation at samples
[out]data_varArray of estimation variance at samples

◆ st_krige_manage()

static int st_krige_manage ( int  mode,
int  nvar,
Model model,
ANeigh neigh 
)
static

Management of internal arrays used by kriging procedure

Returns
Error return code
Parameters
[in]mode1 for allocation; -1 for deallocation
[in]nvarNumber of variables to be calculated
[in]modelModel structure
[in]neighANeigh structure
Remarks
The number of variables corresponds to the number of variables
to be calculated. It is not necessarily equal to the number of
variables contained in Model (when kriging a linear combination
of variables for example): hence the use of the 'nvar' passed
as an argument

◆ st_krige_manage_basic()

static int st_krige_manage_basic ( int  mode,
int  nech,
int  nmax,
int  nvar,
int  nfeq 
)
static

Management of internal arrays used by kriging procedure

Returns
Error return code
Parameters
[in]mode1 for allocation; -1 for deallocation
[in]nechNumber of samples in the Input Db (only used for the neighborhood search, if any)
[in]nmaxMaximum number of samples per neighborhood
[in]nvarNumber of variables (to be calculated)
[in]nfeqNumber of drift equations

◆ st_lhs_exp()

static void st_lhs_exp ( double *  covdd,
int  cov_radius,
int  flag_sym,
int  nfeq,
int  nbefore,
int  nafter,
int  neq 
)
static

Establish the L.H.S. of the Kriging system in the case of the discretized covariances

Parameters
[in]covddArray of discretized covariance (data-data)
[in]cov_radiusRadius of the covariance array
[in]flag_sym1 for symmetrized covariance
[in]nfeq0 or 1 drift function(s)
[in]nbeforeNumber of samples in neighborhood before target
[in]nafterNumber of samples in neighborhood after target
[in]neqNumber of kriging equations

◆ st_lhs_exp_3D()

static void st_lhs_exp_3D ( int  nech,
int  nfeq,
const int  nei_ss[3],
const int  nei_nn[3],
const int  cov_ss[3],
const int  cov_nn[3],
const int *  nei_cur,
const double *  cov_tot,
double  nugget 
)
static

Establish the kriging L.H.S. using discretized covariances

Parameters
[in]nechNumber of samples in the Neighborhood
[in]nfeqNumber of drift functions
[in]nei_ssArray of dimensions of the Neighborhood
[in]nei_nnArray of radius of the Neighborhood
[in]cov_ssArray of dimensions of the Covariance array
[in]cov_nnArray of radius of the Covariance array
[in]nei_curArray containing the current neighborhood
[in]cov_totArray containing the total variable covariance
[in]nuggetAmount of additional Nugget Effect

◆ st_model_manage()

static int st_model_manage ( int  mode,
Model model 
)
static

Management of internal arrays used by cov and drift functions

Returns
Error return code
Parameters
[in]mode1 for allocation; -1 for deallocation
[in]modelModel structure
Remarks
This function manages covariance internal arrays with dimension
equal to the number of variables in the Model

◆ st_neigh_diff()

static int st_neigh_diff ( const int  nei_ss[3],
const int  nei_nn[3],
int *  nei_ref,
const int *  nei_cur 
)
static

Check if two neighborhood patterns are similar

Returns
1 if the patterns are different; 0 otherwise
Parameters
[in]nei_ssArray of dimensions of the Neighborhood
[in]nei_nnArray of radius of the Neighborhood
[in]nei_refArray containing the reference neighborhood
[in]nei_curArray containing the current neighborhood

◆ st_neigh_find()

static VectorInt st_neigh_find ( DbGrid db,
int  ix0,
int  iy0,
int  iz0,
const int  nei_ss[3],
const int  nei_nn[3],
int *  nei_cur 
)
static

Find the neighborhood of a pixel

Parameters
[in]dbinput Db structure
[in]ix0index of the pixel along X
[in]iy0index of the pixel along Y
[in]iz0index of the pixel along Z
[in]nei_ssArray of dimensions of the Neighborhood
[in]nei_nnArray of radius of the Neighborhood
[out]nei_curArray containing the neighborhood

◆ st_ranks_other()

static VectorInt st_ranks_other ( int  nech,
const VectorInt ranks1,
const VectorInt ranks2 
)
static

Allocate a vector of sample ranks excluding already selected pivots

Returns
Pointer to the newly create integer vector
Parameters
[in]nechNumber of samples
[in]ranks1Ranks of exact pivots
[in]ranks2Ranks of ACP pivots
Remarks
The output array must be free by the calling function

◆ st_relative_position_array()

static int* st_relative_position_array ( int  mode,
int  neq,
int *  rel_arg 
)
static

Manage the relative position array

Parameters
[in]mode1 for creating, -1 for deleting
[in]neqNumber of kriging equations
[in]rel_argRelative position array (used for deletion)

◆ st_result_kriging_print()

static void st_result_kriging_print ( int  flag_xvalid,
int  nvar,
int  status 
)
static

Print the results

Parameters
[in]flag_xvalidwhen cross-validation option is switched ON 1: Z*-Z and (Z*-Z)/S* 2: Z* and S* > 0 for ONE Point out < 0 for excluding information with same code
[in]nvarNumber of variables
[in]statusKriging error status

◆ st_rhs_exp()

static void st_rhs_exp ( double *  covd0,
int  cov_radius,
int  flag_sym,
int  nfeq,
int  nbefore,
int  nafter,
int  neq 
)
static

Establish the R.H.S. of the Kriging system in the case of the discretized covariances

Parameters
[in]covd0Array of discretized covariance (data-data)
[in]cov_radiusRadius of the covariance array
[in]flag_sym1 for symmetrized covariance
[in]nfeq0 or 1 drift function(s)
[in]nbeforeNumber of samples in neighborhood before target
[in]nafterNumber of samples in neighborhood after target
[in]neqNumber of equations

◆ st_rhs_exp_3D()

static void st_rhs_exp_3D ( int  nech,
int  nfeq,
const int  nei_ss[3],
const int  nei_nn[3],
const int  cov_ss[3],
const int  cov_nn[3],
const int *  nei_cur,
const double *  cov_res 
)
static

Establish the kriging R.H.S. using discretized covariances

Parameters
[in]nechNumber of samples in the neighborhood
[in]nfeqNumber of drift functions
[in]nei_ssArray of dimensions of the Neighborhood
[in]nei_nnArray of radius of the Neighborhood
[in]cov_ssArray of dimensions of the Covariance array
[in]cov_nnArray of radius of the Covariance array
[in]nei_curArray containing the current neighborhood
[in]cov_resArray containing the residual variable covariance

◆ st_sampling_krige_data()

static int st_sampling_krige_data ( Db db,
Model model,
double  beta,
VectorInt ranks1,
VectorInt ranks2,
VectorInt rother,
int *  ntot_arg,
int *  nutil_arg,
VectorInt rutil,
double **  tutil_arg,
double **  invsig_arg 
)
static

Establishing the kriging system with exact and ACP points

Returns
Error retun code
Parameters
[in]dbDb structure
[in]modelModel structure
[in]betaThresholding value
[in]ranks1Ranks of samples (exact)
[in]ranks2Ranks of samples (ACP)
[in]rotherRanks of the idle samples (modified by routine)
[out]ntot_argNumber of pivots
[out]nutil_argNumber of active samples
[out]rutilRank of the active samples
[out]tutil_argReturned array for the U array
[out]invsig_argReturned array for Inverse Sigma

◆ st_vario_dump()

static void st_vario_dump ( FILE *  file,
int  ix0,
int  iy0,
const int  cov_ss[3],
const int  cov_nn[3],
const int *  num_tot,
const double *  cov_tot 
)
static

Dump the contents of the covariance maps

Parameters
[in]fileFILE structure where the dmp must be produced
[in]ix0Rank of the trace along X (-1 for the reference)
[in]iy0Rank of the trace along Y (-1 for the reference)
[in]cov_ssArray of dimensions of the Covariance array
[in]cov_nnArray of radius of the Covariance array
[out]num_totArray containing the numb er of pairs
[out]cov_totArray containing the covariance of the total variable

Variable Documentation

◆ covaux_global

double* covaux_global
static

◆ COVINT

CovInternal COVINT
static

◆ d1_1_global

double * d1_1_global
static

◆ d1_2_global

double * d1_2_global
static

◆ d1_global

VectorDouble d1_global
static

◆ d1_t_global

VectorDouble d1_t_global
static

◆ DBIN

Db* DBIN
static

◆ DBOUT

Db * DBOUT
static

◆ FLAG_COLK

int FLAG_COLK
static

◆ FLAG_EST

int FLAG_EST
static

◆ flag_global

int* flag_global
static

◆ FLAG_PROF

int FLAG_PROF
static

◆ FLAG_SIMU

int FLAG_SIMU
static

◆ FLAG_STD

int FLAG_STD
static

◆ FLAG_VARZ

int FLAG_VARZ
static

◆ IECH_OUT

int IECH_OUT = -1
static

◆ INH_FLAG_LIMIT

int INH_FLAG_LIMIT = 1
static

◆ INH_FLAG_VERBOSE

int INH_FLAG_VERBOSE = 0
static

◆ IPTR_EST

int IPTR_EST
static

◆ IPTR_NBGH

int IPTR_NBGH
static

◆ IPTR_STD

int IPTR_STD
static

◆ IPTR_VARZ

int IPTR_VARZ
static

◆ KOPTION

Koption* KOPTION
static

◆ KRIGE_INIT

int KRIGE_INIT = 0
static

◆ lhs_global

double* lhs_global
static

◆ MODEL_INIT

int MODEL_INIT = 0
static

◆ RANK_COLCOK

int* RANK_COLCOK
static

◆ rhs_global

double * rhs_global
static

◆ string

char string[100]
static

◆ var0_global

double * var0_global
static

◆ wgt_global

double * wgt_global
static

◆ zam1_global

double * zam1_global
static