1.4.0
CCC
 
variopgs.cpp File Reference
#include "geoslib_f.h"
#include "geoslib_old_f.h"
#include "geoslib_define.h"
#include "geoslib_f_private.h"
#include "Variogram/Vario.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/Law.hpp"
#include "Basic/MathFunc.hpp"
#include "Stats/Classical.hpp"
#include "Basic/AException.hpp"
#include "Basic/OptDbg.hpp"
#include "LithoRule/Rule.hpp"
#include "LithoRule/RuleShift.hpp"
#include "LithoRule/RuleProp.hpp"
#include "LithoRule/PropDef.hpp"
#include "Db/Db.hpp"
#include "Model/Model.hpp"
#include "Matrix/MatrixSquareSymmetric.hpp"
#include "Matrix/MatrixFactory.hpp"
#include "Enum/EOperator.hpp"
#include <math.h>
#include <string.h>

Functions

void set_test_discrete (bool flag_discret)
 
static Relemst_relem_alloc (Split *old_split)
 
static Splitst_split_alloc (Relem *old_relem)
 
static int st_define_fipos (int oper, int side)
 
static void st_relem_define (Relem *relem, int nfacies, const VectorInt &facies, int side, const int *poss)
 
static void st_rule_print (int rank, int nbyrule, const int *rules, int *fipos, bool flag_rank, int flag_similar, int flag_igrf, double score)
 
static void st_rules_print (const char *title, int nrule, int nbyrule, int *rules, int *fipos)
 
static void st_relem_subdivide (Relem *relem0, int half, int noper)
 
static Splitst_split_free (Split *split)
 
static Relemst_relem_free (Relem *relem)
 
static void st_variogram_define_vars (Vario *vario, const Rule *rule, int ngrf)
 
static void st_set_bounds (Db *db, int flag_one, int ngrf, int nfacies, int ifac, int iech, double t1min, double t1max, double t2min, double t2max)
 
static void st_set_rho (double rho, Local_Pgs *local_pgs)
 
static double st_get_proba_ind (double correl, double *low, double *up, int iconf)
 
static int st_calculate_thresh_stat (Local_Pgs *local_pgs)
 
static int st_vario_pgs_variable (int mode, int ngrf, int nfacies, int flag_one, int flag_prop, Db *db, PropDef *propdef, const Rule *rule)
 
static Rulest_rule_encode (const int *string)
 
static double st_extract_trace (Local_Pgs *local_pgs)
 
static void st_variogram_patch_C00 (Local_Pgs *local_pgs, Vario *vario, int idir, double rho)
 
static void trace_add_row (Local_Pgs *local_pgs)
 
static double st_func_search_stat (double correl, void *user_data)
 
static double st_func_search_nostat (double correl, void *user_data)
 
static void trace_define (Local_Pgs *local_pgs, double value0, double value1, int origin, int number, const double *values)
 
static int st_varcalc_from_vario_stat (Vario *vario, Local_Pgs *local_pgs, int ngrf)
 
static void st_define_trace (int flag_rho, int flag_correl, Local_Pgs *local_pgs)
 
static void st_retrace_define (Local_Pgs *local_pgs)
 
static void st_varcalc_uncorrelated_grf (Local_Pgs *local_pgs, int idir)
 
static double st_rule_calcul (Local_Pgs *local_pgs, int *string)
 
static int st_permut (int value, int igrf)
 
static int st_fipos_encode (VectorInt &fgrf)
 
static void st_fipos_decode (int fipos, VectorInt &fgrf)
 
static int st_update_orientation (int fac0, int igrf_cas, VectorInt &fgrf)
 
static int st_same_score (Relem *relem, int ir0, int igrf_cas, VectorInt &fgrf, VectorInt &fcmp)
 
static VectorDouble st_relem_evaluate (Relem *relem, int verbose, VectorInt &fgrf, VectorInt &fcmp, Local_Pgs *local_pgs, int *nscore, int *r_opt)
 
static void st_rule_glue (Relem *relem, int nrule1, int nbyrule1, const int *rules1, const int *fipos1)
 
static void st_rule_product (Split *split, int nprod, int nrule1, int nbyrule1, int *rules1, int *fipos1, int nrule2, int nbyrule2, int *rules2, int *fipos2)
 
static void st_split_collapse (Split *split, int verbose)
 
static void st_relem_explore (Relem *relem, int verbose)
 
Vario_Ordervario_order_manage (int mode, int flag_dist, int size_aux, Vario_Order *vorder)
 
int vario_order_add (Vario_Order *vorder, int iech, int jech, void *aux_iech, void *aux_jech, int ipas, int idir, double dist)
 
void vario_order_print (Vario_Order *vorder, int idir_target, int ipas_target, int verbose)
 
Vario_Ordervario_order_final (Vario_Order *vorder, int *npair)
 
void vario_order_get_indices (Vario_Order *vorder, int ipair, int *iech, int *jech, double *dist)
 
void vario_order_get_auxiliary (Vario_Order *vorder, int ipair, char *aux_iech, char *aux_jech)
 
void vario_order_get_bounds (Vario_Order *vorder, int idir, int ipas, int *ifirst, int *ilast)
 
static int invgen (MatrixSquareSymmetric &a, MatrixSquareSymmetric &tabout)
 
static int st_index (int i, int j)
 
static VectorDouble st_compute_params (Local_CorPgs *corpgs, VectorDouble &params_in)
 
static void st_build_correl (Local_CorPgs *corpgs, VectorDouble &params_in, MatrixSquareSymmetric &correl)
 
static void st_update_constraints (Local_CorPgs *corpgs, VectorDouble &Grad, MatrixSquareSymmetric &Hess)
 
static void st_update_constraints_with_JJ (Local_CorPgs *corpgs, VectorDouble &Grad, MatrixSquareSymmetric &Hess, MatrixSquareSymmetric &JJ)
 
static void st_deriv_eigen (Local_CorPgs *corpgs, double eigval, const MatrixSquareGeneral *ev, VectorDouble &d1, MatrixSquareSymmetric &d2)
 
static double st_param_expand (Local_Pgs *local_pgs, int igrf, int jgrf, int idir)
 
static void st_set_modif (Local_CorPgs *corpgs)
 
static void st_define_corpgs (int option, int flag_rho, double rho, Local_Pgs *local_pgs)
 
static int st_get_count (Local_Pgs *local_pgs, int ifac1, int ifac2)
 
static double st_rkl (int maxpts, double x, double y, VectorDouble &lower, VectorDouble &upper, MatrixSquareSymmetric &corr1, MatrixSquareGeneral &covar, MatrixSquareGeneral &temp)
 
static double st_ikl (int maxpts, int index1, int index2, VectorDouble &lower, VectorDouble &upper, MatrixSquareSymmetric &correl)
 
static double st_nkl (VectorDouble &u, double lower, double upper, VectorDouble &invvari, int index2, double meanj, double varj, double stdj)
 
static double st_d2_dkldkl (int maxpts, int index1, int index2, VectorDouble &lower, VectorDouble &upper, MatrixSquareSymmetric &correl)
 
static double st_d2_dkldij (VectorDouble &lower, VectorDouble &upper, MatrixSquareSymmetric &correl)
 
static double st_d2_dkldkj (int index1, int index2, VectorDouble &lower, VectorDouble &upper, MatrixSquareSymmetric &correl)
 
static double st_calcul_stat (Local_Pgs *local_pgs, int flag_deriv, int flag_reset, MatrixSquareSymmetric &correl, VectorDouble &Grad, MatrixSquareSymmetric &Hess, MatrixSquareSymmetric &JJ)
 
static double st_calcul_nostat (Local_Pgs *local_pgs, int flag_deriv, int flag_reset, MatrixSquareSymmetric &correl, VectorDouble &Grad, MatrixSquareSymmetric &Hess, MatrixSquareSymmetric &JJ)
 
static double st_calcul (Local_Pgs *local_pgs, int flag_deriv, int flag_reset, VectorDouble &params, VectorDouble &Grad, MatrixSquareSymmetric &Hess, MatrixSquareSymmetric &JJ)
 
static void st_initialize_params (Local_CorPgs *corpgs)
 
static double st_optim_onelag_pgs (Local_Pgs *local_pgs, double tolsort, int new_val)
 
static int st_discard_point (Local_Pgs *local_pgs, int iech)
 
static int st_variogram_geometry_pgs_final (Local_Pgs *local_pgs)
 
static void st_variogram_geometry_pgs_correct (Local_Pgs *local_pgs, Vario *vario, int idir)
 
static int st_variogram_geometry_pgs_calcul (Local_Pgs *local_pgs, Vario *vario, int idir)
 
static void st_set_opt_correl (int opt, Local_CorPgs *corpgs)
 
static double st_varcalc_correlated_grf (Local_Pgs *local_pgs, int idir)
 
static void st_manage_corpgs (Local_CorPgs *local_corpgs)
 
static void st_manage_trace (Local_TracePgs *local_tracepgs)
 
static void st_manage_pgs (int mode, Local_Pgs *local_pgs, Db *db=nullptr, const Rule *rule=nullptr, Vario *vario=nullptr, Vario *varioind=nullptr, Model *model=nullptr, PropDef *propdef=nullptr, int flag_stat=0, int flag_facies=0, int flag_dist=0, int ngrf=0, int nfacies=0, const ECalcVario &calcul_type=ECalcVario::UNDEFINED)
 
static int st_variopgs_calcul_norho (Vario *vario, const Rule *rule, Local_Pgs *local_pgs, int ngrf, int opt_correl, int flag_geometry)
 
static void st_make_some_lags_inactive (Vario *vario)
 
static void st_make_all_lags_active (Vario *vario)
 
static double st_rho_search (double rho, void *user_data)
 
static int st_variopgs_calcul_rho (Vario *vario, const Rule *rule, Local_Pgs *local_pgs, int ngrf, int opt_correl)
 
static int st_check_test_discret (const ERule &mode, int flag_rho)
 
static int st_vario_pgs_check (int flag_db, int flag_rule, int flag_varioind, Db *db, const Db *dbprop, const Vario *vario, Vario *varioind, const Rule *rule)
 
static int st_variogram_pgs_nostat (Db *db, const Db *dbprop, Vario *vario, const Rule *rule, const VectorDouble &propcst, int flag_rho, int opt_correl)
 
static void st_calcul_covmatrix (Local_Pgs *local_pgs, int *flag_ind, int *iconf, double *cov)
 
static double st_get_proba (Local_Pgs *local_pgs, int flag_ind, double *low, double *up, int *iconf, double *cov)
 
static void st_define_bounds (Local_Pgs *local_pgs, int iech1, int iech2, int ifac1, int ifac2, double *low, double *up, double *ploc)
 
static double st_get_value (Local_Pgs *local_pgs, int flag_ind, int iech1, int iech2, int ifac1, int ifac2, int *iconf, double *cov)
 
static void st_variogram_scale (Vario *vario, int idir)
 
static int st_vario_indic_model_nostat (Local_Pgs *local_pgs)
 
static int st_copy_swhh (const Vario *vario1, Vario *vario2, bool flagSw, bool flagHh, bool flagGg)
 
static int st_vario_indic_model_stat (Local_Pgs *local_pgs)
 
static void st_update_variance_stat (Local_Pgs *local_pgs)
 
static void st_update_variance_nostat (Local_Pgs *local_pgs)
 
Variomodel_pgs (Db *db, const VarioParam *varioparam, const RuleProp *ruleprop, const Model *model1, const Model *model2)
 
static int st_variogram_pgs_stat (Db *db, Vario *vario, Vario *varioind, const Rule *rule, const VectorDouble &propcst)
 
Variovariogram_pgs (Db *db, const VarioParam *varioparam, const RuleProp *ruleprop, int flag_rho, int opt_correl)
 
Rule_rule_auto (Db *db, const VarioParam *varioparam, const RuleProp *ruleprop, int ngrfmax, int verbose)
 

Function Documentation

◆ _rule_auto()

Rule* _rule_auto ( Db db,
const VarioParam varioparam,
const RuleProp ruleprop,
int  ngrfmax,
int  verbose 
)

Find the optimal Truncation Scheme from Variopgs score

Returns
The newly created Rule structure
Parameters
[in]dbDb structure
[in]varioparamVarioParam structure for the GRFs
[in]rulepropRuleProp structure
[in]ngrfmaxMaximum number of underlying GRFs (1 or 2)
[in]verboseVerbose flag

◆ invgen()

static int invgen ( MatrixSquareSymmetric a,
MatrixSquareSymmetric tabout 
)
static

Calculate the generalized inverse of a square symmetric matrix

Returns
Error returned code
Parameters
[in]aMatrix to be inverted
[out]taboutInverted matrix

◆ model_pgs()

Vario* model_pgs ( Db db,
const VarioParam varioparam,
const RuleProp ruleprop,
const Model model1,
const Model model2 
)

Evaluate the experimental variogram of indicators in PluriGaussian case

Returns
Error return code
Parameters
[in]dbDb descriptor
[in]varioparamVarioParam structure
[in]rulepropRuleProp structure
[in]model1First Model structure
[in]model2Second Model structure (optional)

◆ set_test_discrete()

void set_test_discrete ( bool  flag_discret)

◆ st_build_correl()

static void st_build_correl ( Local_CorPgs *  corpgs,
VectorDouble params_in,
MatrixSquareSymmetric correl 
)
static

Establish the correlation for C1(h), C12(h), C21(h), C2(h)

Parameters
[in]corpgsLocal_CorPgs structure
[in]params_inArray of parameters
[out]correlCorrelation matrix (Dimension = 4*4)

◆ st_calcul()

static double st_calcul ( Local_Pgs *  local_pgs,
int  flag_deriv,
int  flag_reset,
VectorDouble params,
VectorDouble Grad,
MatrixSquareSymmetric Hess,
MatrixSquareSymmetric JJ 
)
static

Global calculation

Returns
The global score
Parameters
[in]local_pgsLocal_Pgs structure
[in]flag_deriv1 if the derivatives must be calculated
[in]flag_reset1 to update the probability calculations
[in]paramsArray of parameters
[out]GradVector of cumulated gradients (Dimension= 4)
[out]HessMatrix of cumulated Hessian (Dimension= 4*4)
[out]JJMatrix of cumulated JJ (Dimension= 4*4)

◆ st_calcul_covmatrix()

static void st_calcul_covmatrix ( Local_Pgs *  local_pgs,
int *  flag_ind,
int *  iconf,
double *  cov 
)
static

Calculate the covariance matrix

Parameters
[in]local_pgsLocal_Pgs structure
[out]flag_ind1 if the two GRF are independent
[out]iconfArray of ranks of the discretized covariance
[out]covMatrix of covariance

◆ st_calcul_nostat()

static double st_calcul_nostat ( Local_Pgs *  local_pgs,
int  flag_deriv,
int  flag_reset,
MatrixSquareSymmetric correl,
VectorDouble Grad,
MatrixSquareSymmetric Hess,
MatrixSquareSymmetric JJ 
)
static

Global calculation in the non-stationary case

Returns
The global score
Parameters
[in]local_pgsLocal_Pgs structure
[in]flag_deriv1 if the derivatives must be calculated
[in]flag_reset1 to update the probability calculations
[in]correlCorrelation matrix updated
[out]GradVector of cumulated gradients (Dimension= 4)
[out]HessMatrix of cumulated Hessian (Dimension= 4*4)
[out]JJMatrix of cumulated JJ (Dimension= 4*4)

◆ st_calcul_stat()

static double st_calcul_stat ( Local_Pgs *  local_pgs,
int  flag_deriv,
int  flag_reset,
MatrixSquareSymmetric correl,
VectorDouble Grad,
MatrixSquareSymmetric Hess,
MatrixSquareSymmetric JJ 
)
static

Global calculation in the stationary case

Returns
The global score
Parameters
[in]local_pgsLocal_Pgs structure
[in]flag_deriv1 if the derivatives must be calculated
[in]flag_reset1 to update the probability calculations
[in]correlCorrelation matrix updated
[out]GradVector of cumulated gradients (Dimension= 4)
[out]HessMatrix of cumulated Hessian (Dimension= 4*4)
[out]JJMatrix of cumulated JJ (Dimension= 4*4)

◆ st_calculate_thresh_stat()

static int st_calculate_thresh_stat ( Local_Pgs *  local_pgs)
static

Calculate the thresholds in the stationary case

Returns
Error return code
Parameters
[in]local_pgsLocal_Pgs structure

◆ st_check_test_discret()

static int st_check_test_discret ( const ERule &  mode,
int  flag_rho 
)
static

Check if the Discrete Calculations make sens or not

Returns
Error code
Parameters
[in]modeLithotype mode (ENUM_RULES)
[in]flag_rho1 if rho has to be calculated, 0 otherwise

◆ st_compute_params()

static VectorDouble st_compute_params ( Local_CorPgs *  corpgs,
VectorDouble params_in 
)
static

Establish the total vector C1(h), C12(h), C21(h), C2(h)

Parameters
[in]corpgsLocal_CorPgs structure
[in]params_inParameters (Dimension corpgs.npar)
Returns
params Parameters (Dimension = 4)

◆ st_copy_swhh()

static int st_copy_swhh ( const Vario vario1,
Vario vario2,
bool  flagSw,
bool  flagHh,
bool  flagGg 
)
static

Duplicate the information from the input variogram to the output variogram This operation considers (Sw, Hh, Gg) and replicates this information for all directions. Per direction, the information of the first simple input variogram is replicated to all simple and cross-variograms outputs

Returns
Error return code
Parameters
[in]vario1Input Variogram
[out]vario2Output Variogram
[in]flagSwTrue if Sw must be replicated
[in]flagHhTrue if Hh must be replicated
[in]flagGgTrue if Gg must be replicated

◆ st_d2_dkldij()

static double st_d2_dkldij ( VectorDouble lower,
VectorDouble upper,
MatrixSquareSymmetric correl 
)
static

Calculate the gradients for a pair of facies and return it

Returns
Calculate d²S/dC12dC21 and d²S/dC1dC2
Parameters
[in]lowerArray of lower bounds (Dimension = 4)
[in]upperArray of upper bounds (Dimension = 4)
[in]correlCorrelation matrix (Dimension = 4*4)

◆ st_d2_dkldkj()

static double st_d2_dkldkj ( int  index1,
int  index2,
VectorDouble lower,
VectorDouble upper,
MatrixSquareSymmetric correl 
)
static
Returns
Calculate the first-order derivatives
Parameters
[in]index1First derivative index
[in]index2Second derivative index
[in]lowerArray of lower bounds (Dimension = 4)
[in]upperArray of upper bounds (Dimension = 4)
[in]correlCorrelation matrix (Dimension = 4*4)

◆ st_d2_dkldkl()

static double st_d2_dkldkl ( int  maxpts,
int  index1,
int  index2,
VectorDouble lower,
VectorDouble upper,
MatrixSquareSymmetric correl 
)
static
Returns
Calculate second-order derivatives
Parameters
[in]maxptsMaximum number of evaluations in mvndst
[in]index1First derivative index
[in]index2Second derivative index
[in]lowerArray of lower bounds (Dimension = 4)
[in]upperArray of upper bounds (Dimension = 4)
[in]correlCorrelation matrix (Dimension = 4*4)

◆ st_define_bounds()

static void st_define_bounds ( Local_Pgs *  local_pgs,
int  iech1,
int  iech2,
int  ifac1,
int  ifac2,
double *  low,
double *  up,
double *  ploc 
)
static

Define the thresholds of the GRF(s)

Parameters
[in]local_pgsLocal_Pgs structure
[in]iech1Rank of the first sample
[in]iech2Rank of the second sample
[in]ifac1Rank of the first facies
[in]ifac2Rank of the second facies
[out]lowArray of lower thresholds (Dimension: 4)
[out]upArray of upper thresholds (Dimension: 4)
[out]plocArray of proportions (Dimension: 2)

REMARKS: Warning: in the case of TEST_DISCRET, the returned arguments REMARKS: 'low' and 'up' return the ranks in the discretized covariance

◆ st_define_corpgs()

static void st_define_corpgs ( int  option,
int  flag_rho,
double  rho,
Local_Pgs *  local_pgs 
)
static

Define the correlation option

Parameters
[in]optionCorrelation option
  • 0 : full parameters (C1, C12, C21, C2)
  • 1 : symmetrical case (C12 = C21)
  • 2 : residual case
[in]flag_rho1 if rho has to be calculated, 0 otherwise
[in]rhoCorrelation between GRFs
[in,out]local_pgsLocal_Pgs structure

◆ st_define_fipos()

static int st_define_fipos ( int  oper,
int  side 
)
static

◆ st_define_trace()

static void st_define_trace ( int  flag_rho,
int  flag_correl,
Local_Pgs *  local_pgs 
)
static

Define the trace

Parameters
[in]flag_rho1 if rho has to be calculated, 0 otherwise
[in]flag_correl1 for the correlated case; 0 otherwise
[in,out]local_pgsLocal_Pgs structure

◆ st_deriv_eigen()

static void st_deriv_eigen ( Local_CorPgs *  corpgs,
double  eigval,
const MatrixSquareGeneral ev,
VectorDouble d1,
MatrixSquareSymmetric d2 
)
static

Compute the derivatives (first and second) of the smallest eigenvalue

Parameters
[in]corpgsLocal_CorPgs structure
[in]eigvalCurrent eigen value
[out]evOutput array
[out]d1First order derivative
[out]d2Second order derivative

◆ st_discard_point()

static int st_discard_point ( Local_Pgs *  local_pgs,
int  iech 
)
static

Discard a data if:

  • its facies is unknown
  • its thresholds are so close that it leads to a zero probability
Returns
Error return code
Parameters
[in]local_pgsLocal_Pgs structure
[in]iechRank of the sample

◆ st_extract_trace()

static double st_extract_trace ( Local_Pgs *  local_pgs)
static

Extract the information of the Trace

Returns
The calculated score
Parameters
[in]local_pgsLocal_Pgs structure

◆ st_fipos_decode()

static void st_fipos_decode ( int  fipos,
VectorInt fgrf 
)
static

◆ st_fipos_encode()

static int st_fipos_encode ( VectorInt fgrf)
static

◆ st_func_search_nostat()

static double st_func_search_nostat ( double  correl,
void *  user_data 
)
static

Local searching function

Returns
Evaluation value
Parameters
[in]correlCorrelation parameter
[in]user_dataUser Data

◆ st_func_search_stat()

static double st_func_search_stat ( double  correl,
void *  user_data 
)
static

Local searching function

Returns
Evaluation value
Parameters
[in]correlCorrelation parameter
[in]user_dataUser Data

◆ st_get_count()

static int st_get_count ( Local_Pgs *  local_pgs,
int  ifac1,
int  ifac2 
)
static

Count the number of pairs with the target facies

Parameters
[in]local_pgsLocal_Pgs structure
[in]ifac1First target facies (starting from 1)
[in]ifac2Second target facies (starting from 1)

◆ st_get_proba()

static double st_get_proba ( Local_Pgs *  local_pgs,
int  flag_ind,
double *  low,
double *  up,
int *  iconf,
double *  cov 
)
static

Calculate the probability

Returns
Evaluation value
Parameters
[in]local_pgsLocal_Pgs structure
[in]flag_ind1 if the GRFs are independent
[in]lowArray of lower thresholds (Dimension: 4)
[in]upArray of upper thresholds (Dimension: 4)
[in]iconfArray of ranks of the discretized covariance
[in]covCovariance matrix

◆ st_get_proba_ind()

static double st_get_proba_ind ( double  correl,
double *  low,
double *  up,
int  iconf 
)
static

Calculate the probability for two independent GRFs

Returns
Evaluation value
Parameters
[in]correlCorrelation between covariance
[in]lowArray of lower thresholds or lower indices (Dimension: 2)
[in]upArray of upper thresholds or upper indices (Dimension: 2)
[in]iconfRank for the discrete calculation

◆ st_get_value()

static double st_get_value ( Local_Pgs *  local_pgs,
int  flag_ind,
int  iech1,
int  iech2,
int  ifac1,
int  ifac2,
int *  iconf,
double *  cov 
)
static

Calculate the variogram or covariance contribution

Returns
Evaluation value
Parameters
[in]local_pgsLocal_Pgs structure
[in]flag_ind1 if the GRFs are independent
[in]iech1Rank of the first sample
[in]iech2Rank of the second sample
[in]ifac1Rank of the first facies
[in]ifac2Rank of the second facies
[in]iconfArray of ranks of the discretized covariance
[in]covCovariance matrix

◆ st_ikl()

static double st_ikl ( int  maxpts,
int  index1,
int  index2,
VectorDouble lower,
VectorDouble upper,
MatrixSquareSymmetric correl 
)
static
Returns
Calculate
d/(d xk) * d/(d xl)
int_lower1^upper1
int_lower2^upper2
int_lower3^upper3
int_lower4^upper4
gaussian density(x1,x2,x3,x4,rho) dx1 dx2 dx3 dx4
Parameters
[in]maxptsMaximum number of evaluations in mvndst
[in]index1First derivative index
[in]index2Second derivative index
[in]lowerArray of lower bounds
[in]upperArray of upper bounds
[in]correlCorrelation matrix (Dimension = 4*4)

◆ st_index()

static int st_index ( int  i,
int  j 
)
static

Calculate the indexes of each parameter

Parameters
[in]iIndex
[in]jIndex

◆ st_initialize_params()

static void st_initialize_params ( Local_CorPgs *  corpgs)
static

Initialize the parameters

Parameters
[out]corpgsLocal_CorPgs Structure

◆ st_make_all_lags_active()

static void st_make_all_lags_active ( Vario vario)
static

Make all lags active

Parameters
[out]varioVario structure

◆ st_make_some_lags_inactive()

static void st_make_some_lags_inactive ( Vario vario)
static

Make some lags inactive

Parameters
[out]varioVario structure

◆ st_manage_corpgs()

static void st_manage_corpgs ( Local_CorPgs *  local_corpgs)
static

Manage the Local_CorPgs structure

Parameters
[in,out]local_corpgsLocal_CorPgs structure

◆ st_manage_pgs()

static void st_manage_pgs ( int  mode,
Local_Pgs *  local_pgs,
Db db = nullptr,
const Rule rule = nullptr,
Vario vario = nullptr,
Vario varioind = nullptr,
Model model = nullptr,
PropDef propdef = nullptr,
int  flag_stat = 0,
int  flag_facies = 0,
int  flag_dist = 0,
int  ngrf = 0,
int  nfacies = 0,
const ECalcVario &  calcul_type = ECalcVario::UNDEFINED 
)
static

Manage the Local_Pgs structure

Parameters
[in]mode0 initialization; 1 allocation; -1 deallocation
[in,out]local_pgsLocal_Pgs structure
[in]dbDb structure
[in]ruleLithotype Rule definition
[in]varioVario structure
[in]varioindIndicator Vario structure
[in]modelModel structure
[in]propdefPropDef structure
[in]flag_stat1 for stationary; 0 otherwise
[in]flag_facies1 when processed on facies; 0 otherwise
[in]flag_dist1 if distances are stored; 0 otherwise
[in]ngrfNumber of GRFs
[in]nfaciesNumber of facies
[in]calcul_typeType of the calculation (covariance, variogram, ...)

◆ st_manage_trace()

static void st_manage_trace ( Local_TracePgs *  local_tracepgs)
static

Manage the Local_TracePgs structure

Parameters
[in,out]local_tracepgsLocal_TracePgs structure

◆ st_nkl()

static double st_nkl ( VectorDouble u,
double  lower,
double  upper,
VectorDouble invvari,
int  index2,
double  meanj,
double  varj,
double  stdj 
)
static
Returns
Calculate the other derivatives

◆ st_optim_onelag_pgs()

static double st_optim_onelag_pgs ( Local_Pgs *  local_pgs,
double  tolsort,
int  new_val 
)
static

Optimize the lag

Parameters
[in]local_pgsLocal_Pgs structure
[in]tolsortTolerance value
[in]new_valFlag indicating if parameters must be initialized

◆ st_param_expand()

static double st_param_expand ( Local_Pgs *  local_pgs,
int  igrf,
int  jgrf,
int  idir 
)
static

Expand the vector of parameters into C1, C12, C21 and C2 according to the constraints

Returns
Returned parameter
Parameters
[in]local_pgsLocal_Pgs structure
[in]igrfRank of the first variable
[in]jgrfRank of the second variable
[in]idirpositive (1) or negative (-1) distance

◆ st_permut()

static int st_permut ( int  value,
int  igrf 
)
static

◆ st_relem_alloc()

static Relem* st_relem_alloc ( Split old_split)
static

◆ st_relem_define()

static void st_relem_define ( Relem relem,
int  nfacies,
const VectorInt facies,
int  side,
const int *  poss 
)
static

◆ st_relem_evaluate()

static VectorDouble st_relem_evaluate ( Relem relem,
int  verbose,
VectorInt fgrf,
VectorInt fcmp,
Local_Pgs *  local_pgs,
int *  nscore,
int *  r_opt 
)
static

◆ st_relem_explore()

static void st_relem_explore ( Relem relem,
int  verbose 
)
static

◆ st_relem_free()

static Relem* st_relem_free ( Relem relem)
static

◆ st_relem_subdivide()

static void st_relem_subdivide ( Relem relem0,
int  half,
int  noper 
)
static

◆ st_retrace_define()

static void st_retrace_define ( Local_Pgs *  local_pgs)
static

Reset the Local_TracePgs structure

Parameters
[in,out]local_pgsLocal_TracePgs structure

◆ st_rho_search()

static double st_rho_search ( double  rho,
void *  user_data 
)
static

Local searching function for rho

Returns
Evaluation value
Parameters
[in]rhorho parameter
[in]user_dataUser Data

◆ st_rkl()

static double st_rkl ( int  maxpts,
double  x,
double  y,
VectorDouble lower,
VectorDouble upper,
MatrixSquareSymmetric corr1,
MatrixSquareGeneral covar,
MatrixSquareGeneral temp 
)
static

PRUPOSE: Internal function

◆ st_rule_calcul()

static double st_rule_calcul ( Local_Pgs *  local_pgs,
int *  string 
)
static

◆ st_rule_encode()

static Rule* st_rule_encode ( const int *  string)
static

◆ st_rule_glue()

static void st_rule_glue ( Relem relem,
int  nrule1,
int  nbyrule1,
const int *  rules1,
const int *  fipos1 
)
static

◆ st_rule_print()

static void st_rule_print ( int  rank,
int  nbyrule,
const int *  rules,
int *  fipos,
bool  flag_rank,
int  flag_similar,
int  flag_igrf,
double  score 
)
static

◆ st_rule_product()

static void st_rule_product ( Split split,
int  nprod,
int  nrule1,
int  nbyrule1,
int *  rules1,
int *  fipos1,
int  nrule2,
int  nbyrule2,
int *  rules2,
int *  fipos2 
)
static

◆ st_rules_print()

static void st_rules_print ( const char *  title,
int  nrule,
int  nbyrule,
int *  rules,
int *  fipos 
)
static

◆ st_same_score()

static int st_same_score ( Relem relem,
int  ir0,
int  igrf_cas,
VectorInt fgrf,
VectorInt fcmp 
)
static

◆ st_set_bounds()

static void st_set_bounds ( Db db,
int  flag_one,
int  ngrf,
int  nfacies,
int  ifac,
int  iech,
double  t1min,
double  t1max,
double  t2min,
double  t2max 
)
static

Define the bounds for Gaussian integrals and store them in relevant variables

◆ st_set_modif()

static void st_set_modif ( Local_CorPgs *  corpgs)
static

Compute the modif matrix

Parameters
[out]corpgsLocal_CorPgs structure

◆ st_set_opt_correl()

static void st_set_opt_correl ( int  opt,
Local_CorPgs *  corpgs 
)
static

Set the model-type (opt_correl)

Parameters
[in]optThe model-type to set
[out]corpgsLocal_CorPgs structure

◆ st_set_rho()

static void st_set_rho ( double  rho,
Local_Pgs *  local_pgs 
)
static

Modify rho where it is needed

Parameters
[in]rhoRho value
[out]local_pgsLocal_Pgs structure

◆ st_split_alloc()

static Split* st_split_alloc ( Relem old_relem)
static

◆ st_split_collapse()

static void st_split_collapse ( Split split,
int  verbose 
)
static

◆ st_split_free()

static Split* st_split_free ( Split split)
static

◆ st_update_constraints()

static void st_update_constraints ( Local_CorPgs *  corpgs,
VectorDouble Grad,
MatrixSquareSymmetric Hess 
)
static

Update the following matrices according to constraints on model

Parameters
[in]corpgsLocal_CorPgs structure
[in,out]GradVector of gradients (Dimension = npar)
[in,out]HessMatrix of Hessian (Dimension = npar * npar)

◆ st_update_constraints_with_JJ()

static void st_update_constraints_with_JJ ( Local_CorPgs *  corpgs,
VectorDouble Grad,
MatrixSquareSymmetric Hess,
MatrixSquareSymmetric JJ 
)
static

Update the following matrices according to constraints on model

Parameters
[in]corpgsLocal_CorPgs structure
[in,out]GradVector of gradients (Dimension = npar)
[in,out]HessMatrix of Hessian (Dimension = npar * npar)
[in,out]JJMatrix of t(JJ) * JJ (Dimension = npar * npar)

◆ st_update_orientation()

static int st_update_orientation ( int  fac0,
int  igrf_cas,
VectorInt fgrf 
)
static

◆ st_update_variance_nostat()

static void st_update_variance_nostat ( Local_Pgs *  local_pgs)
static

Establish the theoretical variance of the simple and cross-variograms of the indicators in the non-stationary case

Returns
Error return code
Parameters
[in]local_pgsLocal_Pgs structure

◆ st_update_variance_stat()

static void st_update_variance_stat ( Local_Pgs *  local_pgs)
static

Establish the theoretical variance of the simple and cross-variograms of the indicators in the stationary case

Parameters
[in]local_pgsLocal_Pgs structure

◆ st_varcalc_correlated_grf()

static double st_varcalc_correlated_grf ( Local_Pgs *  local_pgs,
int  idir 
)
static

Evaluate the variogram of the underlying GRFs (assuming the two GRFs of the PGS model are correlated)

Parameters
[in]local_pgsLocal_Pgs structure
[in]idirRank of the direction

◆ st_varcalc_from_vario_stat()

static int st_varcalc_from_vario_stat ( Vario vario,
Local_Pgs *  local_pgs,
int  ngrf 
)
static

Performing the variogram calculations (stationary case)

Returns
Error return code
Parameters
[in]varioVario structure for the GRFs to be filled
[in]local_pgsLocal_Pgs structure
[in]ngrfNumber of GRFs

◆ st_varcalc_uncorrelated_grf()

static void st_varcalc_uncorrelated_grf ( Local_Pgs *  local_pgs,
int  idir 
)
static

Evaluate the variogram of one underlying GRF

Parameters
[in]local_pgsLocal_Pgs structure
[in]idirRank of the direction

◆ st_vario_indic_model_nostat()

static int st_vario_indic_model_nostat ( Local_Pgs *  local_pgs)
static

Performing the variogram calculations in the non-stationary case

Returns
Error return code
Parameters
[in]local_pgsLocal_Pgs structure

◆ st_vario_indic_model_stat()

static int st_vario_indic_model_stat ( Local_Pgs *  local_pgs)
static

Performing the variogram calculations in the stationary case

Returns
Error return code
Parameters
[in]local_pgsLocal_Pgs structure

◆ st_vario_pgs_check()

static int st_vario_pgs_check ( int  flag_db,
int  flag_rule,
int  flag_varioind,
Db db,
const Db dbprop,
const Vario vario,
Vario varioind,
const Rule rule 
)
static

Check that the arguments are correct

Returns
Error return code
Parameters
[in]flag_db1 if the input Db must be provided -1 if it is optional 0 if the Db is not tested
[in]flag_rule1 if the Rule must be defined
[in]flag_varioind1 if the Indicator Variogram must be defined
[in]dbDb structure
[in]dbpropDb Grid used for proportions (non-stationary)
[in]varioVario structure for the GRFs to be filled
[in]varioindVario structure for Indicator
[in]ruleLithotype Rule definition

◆ st_vario_pgs_variable()

static int st_vario_pgs_variable ( int  mode,
int  ngrf,
int  nfacies,
int  flag_one,
int  flag_prop,
Db db,
PropDef propdef,
const Rule rule 
)
static

Manage local variables for variopgs calculation (Non-stationary case)

Returns
Error return code
Parameters
[in]modeType of usage 1 for allocation 0 for valuation (rule dependent) -1 for deallocation
[in]ngrfNumber of grfs
[in]nfaciesNumber of facies
[in]flag_one1 for considering only the Facies at data point 0 for considering all facies
[in]flag_prop1 for allocating variable for proportions
[in]dbDb structure
[in]propdefPropDef structure
[in]ruleLithotype Rule definition

◆ st_variogram_define_vars()

static void st_variogram_define_vars ( Vario vario,
const Rule rule,
int  ngrf 
)
static

Establish the array of variances

Parameters
[in,out]varioVario structure for the GRFs to be filled
[in]ruleLithotype Rule definition
[in]ngrfNumber of GRFs

◆ st_variogram_geometry_pgs_calcul()

static int st_variogram_geometry_pgs_calcul ( Local_Pgs *  local_pgs,
Vario vario,
int  idir 
)
static

Determine the Geometry of all pairs

Returns
Error return code
Parameters
[in]local_pgsLocal_Pgs structure
[in]varioVario structure
[in]idirRank of the direction

◆ st_variogram_geometry_pgs_correct()

static void st_variogram_geometry_pgs_correct ( Local_Pgs *  local_pgs,
Vario vario,
int  idir 
)
static

Correct the experimental variogram for GRFs

Parameters
[in]local_pgsLocal_Pgs structure
[in]varioVario structure
[in]idirRank of the direction

◆ st_variogram_geometry_pgs_final()

static int st_variogram_geometry_pgs_final ( Local_Pgs *  local_pgs)
static

Compress the Geometry of all pairs

Returns
Error return code
Parameters
[in]local_pgsLocal_Pgs structure

◆ st_variogram_patch_C00()

static void st_variogram_patch_C00 ( Local_Pgs *  local_pgs,
Vario vario,
int  idir,
double  rho 
)
static

Patch the central value (dist=0) of the covariances

Parameters
[in]local_pgsLocal_Pgs structure
[in]varioVario structure for the GRFs to be filled
[in]idirRank of the direction
[in]rhoCorrelation coefficient

◆ st_variogram_pgs_nostat()

static int st_variogram_pgs_nostat ( Db db,
const Db dbprop,
Vario vario,
const Rule rule,
const VectorDouble propcst,
int  flag_rho,
int  opt_correl 
)
static

Calculate the gaussian variograms

Returns
Error return code
Parameters
[in]dbDb structure
[in]dbpropDb Grid used for proportions (non-stationary)
[in]varioVario structure for the GRFs to be filled
[in]ruleLithotype Rule definition
[in]propcstArray of proportions for the facies
[in]flag_rho1 if the correlation coefficient must be regressed
[in]opt_correl0 full model; 1 symmetrical; 2 residuals

◆ st_variogram_pgs_stat()

static int st_variogram_pgs_stat ( Db db,
Vario vario,
Vario varioind,
const Rule rule,
const VectorDouble propcst 
)
static

Calculate the gaussian variograms in the stationary case

Returns
Error return code
Parameters
[in]dbDb structure (for Space dimension)
[in]varioVario structure for the GRFs to be filled
[in]varioindIndicator Vario structure
[in]ruleLithotype Rule definition
[in]propcstArray of proportions for the facies

◆ st_variogram_scale()

static void st_variogram_scale ( Vario vario,
int  idir 
)
static

Scale the variogram calculations

Parameters
[in]varioVario structure
[in]idirRank of the Direction

◆ st_variopgs_calcul_norho()

static int st_variopgs_calcul_norho ( Vario vario,
const Rule rule,
Local_Pgs *  local_pgs,
int  ngrf,
int  opt_correl,
int  flag_geometry 
)
static

Performing the variogram calculations

Returns
Error return code
Parameters
[in]varioVario structure for the GRFs to be filled
[in]ruleLithotype Rule definition
[in]local_pgsLocal_Pgs structure
[in]ngrfNumber of GRFs
[in]opt_correl0 full model; 1 symetrical; 2 residuals
[out]flag_geometry1 if Geometry must be established per direction 0 if Geometry is already calculated before calling this function

◆ st_variopgs_calcul_rho()

static int st_variopgs_calcul_rho ( Vario vario,
const Rule rule,
Local_Pgs *  local_pgs,
int  ngrf,
int  opt_correl 
)
static

Performing the variogram calculations (in the case of flag.rho)

Returns
Error return code
Parameters
[in]varioVario structure for the GRFs to be filled
[in]ruleLithotype Rule definition
[in]local_pgsLocal_Pgs structure
[in]ngrfNumber of GRFs
[in]opt_correl0 full model; 1 symetrical; 2 residuals

◆ trace_add_row()

static void trace_add_row ( Local_Pgs *  local_pgs)
static

Add a new row to the trace

Parameters
[in]local_pgsLocal_Pgs structure

◆ trace_define()

static void trace_define ( Local_Pgs *  local_pgs,
double  value0,
double  value1,
int  origin,
int  number,
const double *  values 
)
static

Update the Trace array

Parameters
[in]local_pgsLocal_Pgs structure
[in]value0First value in a Trace row
[in]value1Second value in a Trace row
[in]originOrigin for values in record (after 2 heading values)
[in]numberNumber of values assigned
[in]valuesArray of values assigned

◆ vario_order_add()

int vario_order_add ( Vario_Order vorder,
int  iech,
int  jech,
void *  aux_iech,
void *  aux_jech,
int  ipas,
int  idir,
double  dist 
)

Add a record to the Variogram Order structure

Returns
Error return code
Parameters
[in]vorderVario_Order structure
[in]iechRank of the first sample
[in]jechRank of the second sample
[in]aux_iechAuxiliary array for sample 'iech' (or NULL)
[in]aux_jechAuxiliary array for sample 'jech' (or NULL)
[in]ipasRank of the lag
[in]idirRank of the direction (or 0)
[in]distCalculated distance (only stored if flag_dist == 1)

◆ vario_order_final()

Vario_Order* vario_order_final ( Vario_Order vorder,
int *  npair 
)

Resize the array and sort it

Returns
Pointer to the Vario_Order structure
Parameters
[in]vorderVario_Order structure
[in]npairFinal number of pairs

◆ vario_order_get_auxiliary()

void vario_order_get_auxiliary ( Vario_Order vorder,
int  ipair,
char *  aux_iech,
char *  aux_jech 
)

Returns the two auxiliary arrays for a given (ordered) pair

Parameters
[in]vorderVario_Order structure
[in]ipairRank of the sorted pair
[out]aux_iechArray to auxiliary information for sample 'iech'
[out]aux_jechArray to auxiliary information for sample 'jech'

◆ vario_order_get_bounds()

void vario_order_get_bounds ( Vario_Order vorder,
int  idir,
int  ipas,
int *  ifirst,
int *  ilast 
)

Returns the first and last indices matching a target lag

Parameters
[in]vorderVario_Order structure
[in]idirRank of the target direction
[in]ipasRank of the target lag
[out]ifirstRank of the first sample of the lag (included)
[out]ilastRank of the last sample of the lag (excluded)

◆ vario_order_get_indices()

void vario_order_get_indices ( Vario_Order vorder,
int  ipair,
int *  iech,
int *  jech,
double *  dist 
)

Returns the two samples for a given (ordered) pair

Parameters
[in]vorderVario_Order structure
[in]ipairRank of the sorted pair
[out]iechRank of the first sample
[out]jechRank of the second sample
[out]distCalculated distance or TEST (if flag_dist == 0)

◆ vario_order_manage()

Vario_Order* vario_order_manage ( int  mode,
int  flag_dist,
int  size_aux,
Vario_Order vorder 
)

Manage the Variogram Order structure

Returns
Pointer to the Vario_Order structure
Parameters
[in]modeUsage:
  • 1 : to initialize
  • 0 : to clean the geometry
  • -1 : to delete
[in]flag_dist1 if distances are stored; 0 otherwise
[in]size_auxSize (in bytes) of the auxiliary array
[in]vorderVario_Order structure

◆ vario_order_print()

void vario_order_print ( Vario_Order vorder,
int  idir_target,
int  ipas_target,
int  verbose 
)

Print the Vario_Order structure

Parameters
[in]vorderVario_Order structure
[in]idir_targetRank of the target direction (starting from 0) or -1
[in]ipas_targetRank of the target lag (starting from 0) or -1
[in]verbose1 for a complete printout

◆ variogram_pgs()

Vario* variogram_pgs ( Db db,
const VarioParam varioparam,
const RuleProp ruleprop,
int  flag_rho,
int  opt_correl 
)

Calculate the Gaussian variograms

Returns
Error return code
Parameters
[in]dbDb structure
[in]varioparamVarioParam structure for the GRFs
[in]rulepropRuleProp structure
[in]flag_rho1 if the correlation coefficient must be regressed
[in]opt_correl0 full model; 1 symmetrical; 2 residuals
Remarks
This is simply a routine dispatching between the stationary function
and the non-stationary one