gstlearn  0.2.1
Geostatistics & Machine Learning toolbox
Utilities.hpp File Reference
#include "gstlearn_export.hpp"
#include "geoslib_define.h"
#include "Basic/VectorNumT.hpp"
#include <map>
#include <cmath>
#include <math.h>

Macros

#define DOUBLE_NA   TEST
 
#define INT_NA   ITEST
 
#define STRING_NA   "NA"
 
#define FLOAT_NA   static_cast<float>(TEST)
 

Functions

GSTLEARN_EXPORT bool isInteger (double value, double eps=EPSILON10)
 
GSTLEARN_EXPORT int getClosestInteger (double value)
 
GSTLEARN_EXPORT bool isMultiple (int nbig, int nsmall)
 
GSTLEARN_EXPORT bool isOdd (int number)
 
GSTLEARN_EXPORT bool isEven (int number)
 
GSTLEARN_EXPORT double getMin (double val1, double val2)
 
GSTLEARN_EXPORT double getMax (double val1, double val2)
 
GSTLEARN_EXPORT double ut_deg2rad (double angle)
 
GSTLEARN_EXPORT double ut_rad2deg (double angle)
 
GSTLEARN_EXPORT int FFFF (double value)
 
GSTLEARN_EXPORT int IFFFF (int value)
 
GSTLEARN_EXPORT double getTEST ()
 
GSTLEARN_EXPORT int getITEST ()
 
template<typename T >
getNA ()
 
template<>
double getNA ()
 
template<>
int getNA ()
 
template<>
String getNA ()
 
template<>
float getNA ()
 
template<typename T >
bool isNA (const T &v)
 
template<>
bool isNA (const double &v)
 
template<>
bool isNA (const int &v)
 
template<>
bool isNA (const String &v)
 
template<>
bool isNA (const float &v)
 
GSTLEARN_EXPORT void ut_tab_unique (int ntab, double *tab, int *neff)
 
GSTLEARN_EXPORT void ut_sort_double (int safe, int nech, int *ind, double *value)
 
GSTLEARN_EXPORT void ut_sort_int (int safe, int nech, int *ind, int *value)
 
GSTLEARN_EXPORT void ut_statistics (int nech, double *tab, double *sel, double *wgt, int *nval, double *mini, double *maxi, double *delta, double *mean, double *stdv)
 
GSTLEARN_EXPORT void ut_stats_mima (int nech, double *tab, double *sel, int *nvalid, double *mini, double *maxi)
 
GSTLEARN_EXPORT void ut_stats_mima_print (const char *title, int nech, double *tab, double *sel)
 
GSTLEARN_EXPORT void ut_facies_statistics (int nech, double *tab, double *sel, int *nval, int *mini, int *maxi)
 
GSTLEARN_EXPORT void ut_classify (int nech, double *tab, double *sel, int nclass, double start, double pas, int *nmask, int *ntest, int *nout, int *classe)
 
GSTLEARN_EXPORT double ut_median (double *tab, int ntab)
 
GSTLEARN_EXPORT void ut_normalize (int ntab, double *tab)
 
GSTLEARN_EXPORT double ut_cnp (int n, int k)
 
GSTLEARN_EXPORT double * ut_pascal (int ndim)
 
GSTLEARN_EXPORT int * ut_combinations (int n, int maxk, int *ncomb)
 
GSTLEARN_EXPORT void ut_shuffle_array (int nrow, int ncol, double *tab)
 
GSTLEARN_EXPORT VectorInt getListActiveToAbsolute (const VectorDouble &sel)
 
GSTLEARN_EXPORT std::map< int, int > getMapAbsoluteToRelative (const VectorDouble &sel, bool verbose=false)
 
GSTLEARN_EXPORT int getRankMapAbsoluteToRelative (const std::map< int, int > &map, int iabs)
 
GSTLEARN_EXPORT int getRankMapRelativeToAbsolute (const std::map< int, int > &map, int irel)
 

Macro Definition Documentation

◆ DOUBLE_NA

#define DOUBLE_NA   TEST

◆ FLOAT_NA

#define FLOAT_NA   static_cast<float>(TEST)

◆ INT_NA

#define INT_NA   ITEST

◆ STRING_NA

#define STRING_NA   "NA"

Function Documentation

◆ FFFF()

GSTLEARN_EXPORT int FFFF ( double  value)

Checks if a double value is TEST

Returns
1 if a TEST value is encountered; 0 otherwise
Parameters
[in]valueValue to be tested

◆ getClosestInteger()

GSTLEARN_EXPORT int getClosestInteger ( double  value)

◆ getITEST()

GSTLEARN_EXPORT int getITEST ( )

◆ getListActiveToAbsolute()

GSTLEARN_EXPORT VectorInt getListActiveToAbsolute ( const VectorDouble sel)

Returns the list of absolute indices for the only active samples A sample is active if its 'sel' value is equal to 1

Parameters
selVector giving the status of all samples (Dimension: absolute)
Returns

◆ getMapAbsoluteToRelative()

GSTLEARN_EXPORT std::map<int, int> getMapAbsoluteToRelative ( const VectorDouble sel,
bool  verbose 
)

Returns the map such that MAP[iabs] = iact. A sample is active if its 'sel' value is equal to 1

Parameters
selVector giving the status of all samples (Dimension: absolute)
verboseVerbose flag
Returns
The map (dimension: nrel)

◆ getMax()

GSTLEARN_EXPORT double getMax ( double  val1,
double  val2 
)

◆ getMin()

GSTLEARN_EXPORT double getMin ( double  val1,
double  val2 
)

◆ getNA() [1/5]

template<typename T >
T getNA ( )
inline

◆ getNA() [2/5]

template<>
double getNA ( )
inline

◆ getNA() [3/5]

template<>
int getNA ( )
inline

◆ getNA() [4/5]

template<>
String getNA ( )
inline

◆ getNA() [5/5]

template<>
float getNA ( )
inline

◆ getRankMapAbsoluteToRelative()

GSTLEARN_EXPORT int getRankMapAbsoluteToRelative ( const std::map< int, int > &  map,
int  iabs 
)

Returns the rank of the relative grid node from its absolute index using the Map

Parameters
mapThe <int,int> map
iabsAbsolute rank of the grid node
Returns
Rank of the corresponding active (relative) grid node (or -1 is not found)

◆ getRankMapRelativeToAbsolute()

GSTLEARN_EXPORT int getRankMapRelativeToAbsolute ( const std::map< int, int > &  map,
int  irel 
)

◆ getTEST()

GSTLEARN_EXPORT double getTEST ( )

◆ IFFFF()

GSTLEARN_EXPORT int IFFFF ( int  value)

Checks if an integer value is TEST

Returns
1 if a ITEST value is encountered; 0 otherwise
Parameters
[in]valueValue to be tested

◆ isEven()

GSTLEARN_EXPORT bool isEven ( int  number)

◆ isInteger()

GSTLEARN_EXPORT bool isInteger ( double  value,
double  eps = EPSILON10 
)

◆ isMultiple()

GSTLEARN_EXPORT bool isMultiple ( int  nbig,
int  nsmall 
)

◆ isNA() [1/5]

template<typename T >
bool isNA ( const T &  v)
inline

◆ isNA() [2/5]

template<>
bool isNA ( const double &  v)
inline

◆ isNA() [3/5]

template<>
bool isNA ( const int &  v)
inline

◆ isNA() [4/5]

template<>
bool isNA ( const String v)
inline

◆ isNA() [5/5]

template<>
bool isNA ( const float &  v)
inline

◆ isOdd()

GSTLEARN_EXPORT bool isOdd ( int  number)

◆ ut_classify()

GSTLEARN_EXPORT void ut_classify ( int  nech,
double *  tab,
double *  sel,
int  nclass,
double  start,
double  pas,
int *  nmask,
int *  ntest,
int *  nout,
int *  classe 
)

Classify the samples into integer sieves

Parameters
[in]nechNumber of samples
[in]tabArray of values
[in]selArray containing the Selection or NULL
[in]nclassNumber of sieve classes
[in]startStarting sieve value
[in]pasWidth of the sieve
[out]nmaskNumber of masked values
[out]ntestNumber of undefined values
[out]noutNumber of values outside the classes
[out]classeArray for number of samples per sieve

◆ ut_cnp()

GSTLEARN_EXPORT double ut_cnp ( int  n,
int  k 
)

Compute combinations(n,k)

Returns
Return the number of combinations of 'k' objects amongst 'n'
Parameters
[in]nTotal number of objects (>= 1)
[in]kSelected number of objects (>= 1)

◆ ut_combinations()

GSTLEARN_EXPORT int* ut_combinations ( int  n,
int  maxk,
int *  ncomb 
)

Return all the combinations of k within n

Returns
Return all the combinations of 'k' objects amongst 'n'
Parameters
[in]nTotal number of objects (>1)
[in]maxkSelected number of objects (1<=maxk<n)
[out]ncombNumber of combinations
Remarks
The calling function must free the returned array.

◆ ut_deg2rad()

GSTLEARN_EXPORT double ut_deg2rad ( double  angle)

Translates from degree to radian

Parameters
[in]angleAngle in degrees

◆ ut_facies_statistics()

GSTLEARN_EXPORT void ut_facies_statistics ( int  nech,
double *  tab,
double *  sel,
int *  nval,
int *  mini,
int *  maxi 
)

Returns the statistics of an array containing the facies

Parameters
[in]nechNumber of samples
[in]tabArray of values
[in]selArray containing the Selection or NULL
[out]nvalNumber of active values
[out]miniMinimum value
[out]maxiMaximum value

◆ ut_median()

GSTLEARN_EXPORT double ut_median ( double *  tab,
int  ntab 
)

Calculate the median from a table of values

Returns
The median value
Parameters
[in]tabArray of values
[in]ntabNumber of samples

◆ ut_normalize()

GSTLEARN_EXPORT void ut_normalize ( int  ntab,
double *  tab 
)

Normalize a vector

Parameters
[in]ntabVector dimension
[in,out]tabVector to be normalized

◆ ut_pascal()

GSTLEARN_EXPORT double* ut_pascal ( int  ndim)

Create the matrix containing the Pascal Triangle coefficients

Returns
A matrix (Dimension: ndim * ndim) containing the coefficients
or NULL if core allocation problem has been encountered
Parameters
[in]ndimSize of the matrix
Remarks
The calling function must free the returned matrix

◆ ut_rad2deg()

GSTLEARN_EXPORT double ut_rad2deg ( double  angle)

Translates from radian to degree

Parameters
[in]angleAngle in radian

◆ ut_shuffle_array()

GSTLEARN_EXPORT void ut_shuffle_array ( int  nrow,
int  ncol,
double *  tab 
)

Shuffle an array (by line)

Parameters
[in]nrowNumber of rows
[in]ncolNumber of columns
[in,out]tabArray to be suffled

◆ ut_sort_double()

GSTLEARN_EXPORT void ut_sort_double ( int  safe,
int  nech,
int *  ind,
double *  value 
)

Sorts the (double) array value() and the array ind() in the ascending order of value

Parameters
[in]safe1 if the value array if preserved 0 if the value array is also sorted
[in]nechnumber of samples
[out]indoutput int array
[out]valueinput and output array
Remarks
If ind = NULL, ind is ignored

◆ ut_sort_int()

GSTLEARN_EXPORT void ut_sort_int ( int  safe,
int  nech,
int *  ind,
int *  value 
)

Sorts the (integer) array value() and the array ind() in the ascending order of value

Parameters
[in]safe1 if the value array if preserved 0 if the value array is also sorted
[in]nechnumber of samples
[out]indoutput int array
[out]valueinput and output array
Remarks
If ind = NULL, ind is ignored

◆ ut_statistics()

GSTLEARN_EXPORT void ut_statistics ( int  nech,
double *  tab,
double *  sel,
double *  wgt,
int *  nval,
double *  mini,
double *  maxi,
double *  delta,
double *  mean,
double *  stdv 
)

Returns the statistics of an array

Parameters
[in]nechNumber of samples
[in]tabArray of values
[in]selArray containing the Selection or NULL
[in]wgtArray containing the Weights or NULL
[out]nvalNumber of active values
[out]miniMinimum value
[out]maxiMaximum value
[out]deltaDistance between the minimum and the maximum
[out]meanMean
[out]stdvStandard Deviation

◆ ut_stats_mima()

GSTLEARN_EXPORT void ut_stats_mima ( int  nech,
double *  tab,
double *  sel,
int *  nvalid,
double *  mini,
double *  maxi 
)

Returns the minimum and maximum of an array

Parameters
[in]nechNumber of samples
[in]tabArray of values
[in]selArray containing the Selection or NULL
[in,out]nvalidNumber of valid samples
[in,out]miniMinimum value
[in,out]maxiMaximum value
Remarks
The calculation starts with the initial values for minimum,
maximum andl nvalid arguments (used in input).
If no default value is defined, set them minimum and maximum to TEST
and set nvalid to 0

◆ ut_stats_mima_print()

GSTLEARN_EXPORT void ut_stats_mima_print ( const char *  title,
int  nech,
double *  tab,
double *  sel 
)

Print minimum and maximum of an array

Parameters
[in]titleTitle
[in]nechNumber of samples
[in]tabArray of values
[in]selArray containing the Selection or NULL

◆ ut_tab_unique()

GSTLEARN_EXPORT void ut_tab_unique ( int  ntab,
double *  tab,
int *  neff 
)

Returns the unique occurrence of values in a vector of values

Parameters
[in]ntabNumber of values
[in]tabArray of values
[out]neffActual number of different values
Remarks
The 'neff' values are placed at the beginning of 'tab' in output