1.2.2
CCC
 
db.cpp File Reference
#include "geoslib_f.h"
#include "geoslib_old_f.h"
#include "Space/ASpaceObject.hpp"
#include "Polygon/Polygons.hpp"
#include "Basic/AException.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/String.hpp"
#include "Basic/GlobalEnvironment.hpp"
#include "Db/Db.hpp"
#include "Db/DbStringFormat.hpp"
#include <math.h>

Functions

int compat_NDIM (Db *db1, Db *db2)
 
void db_grid_print (Db *db)
 
int db_vector_get_att_sel_compress (Db *db, int iatt, int *number, double *tab)
 
int db_vector_get_att (const Db *db, int iatt, double *tab)
 
int db_vector_get_att_sel (Db *db, int iatt, double *tab)
 
int db_vector_get (Db *db, const ELoc &locatorType, int item, double *tab)
 
int db_selection_get (const Db *db, int item, double *tab)
 
int db_vector_put (Db *db, const ELoc &locatorType, int locatorIndex, double *tab)
 
int get_LOCATOR_NITEM (const Db *db, const ELoc &locatorType)
 
int exist_LOCATOR (Db *db, const ELoc &locatorType)
 
double get_LOCATOR_ITEM (Db *db, const ELoc &locatorType, int item, int iech)
 
void set_LOCATOR_ITEM (Db *db, const ELoc &locatorType, int item, int iech, double value)
 
int * db_indg_free (int *indice)
 
int * db_indg_alloc (const Db *db)
 
double * db_vector_free (double *tab)
 
double * db_vector_alloc (const Db *db)
 
int db_coorvec_get (const Db *db, int idim, double *tab)
 
int db_coorvec_put (Db *db, int idim, double *tab)
 
int db_attribute_identify (const Db *db, const ELoc &locatorType, int item)
 
double * db_sample_free (double *tab)
 
double * db_sample_alloc (const Db *db, const ELoc &locatorType)
 
int db_sample_load (Db *db, const ELoc &locatorType, int iech, double *tab)
 
int db_sample_get_att (Db *db, int iech, int number, int iatt, double *tab)
 
void db_sample_put_att (Db *db, int iech, int number, int iatt, double *tab)
 
double distance_inter (const Db *db1, const Db *db2, int iech1, int iech2, double *dist_vect)
 
double distance_intra (const Db *db, int iech1, int iech2, double *dist_vect)
 
double distance_grid (DbGrid *db, int flag_moins1, int iech1, int iech2, double *dist_vect)
 
double bench_distance (const Db *db, int iech1, int iech2)
 
double cylinder_radius (const Db *db, int iech1, int iech2, const VectorDouble &codir)
 
int db_index_grid_to_sample (const DbGrid *db, const int *indg)
 
void db_index_sample_to_grid (const DbGrid *db, int iech, int *indg)
 
int db_index_sorted_in_grid (const DbGrid *db, int iech, int *indg)
 
void db_sample_print (Db *db, int iech, int flag_ndim, int flag_nvar, int flag_nerr)
 
void db_extension (const Db *db, VectorDouble &mini, VectorDouble &maxi, bool flag_preserve)
 
int db_center (Db *db, double *center)
 
int db_extension_diag (const Db *db, double *diag)
 
double db_epsilon_distance (Db *db)
 
int db_attribute_range (const Db *db, int iatt, double *mini, double *maxi, double *delta)
 
int db_grid_define_coordinates (DbGrid *db)
 
Dbdb_create_from_target (const double *target, int ndim, int flag_add_rank)
 
String db_name_get_by_att (const Db *db, int iatt)
 
String db_name_get_by_col (Db *db, int icol)
 
int db_name_set (Db *db, int iatt, const String &name)
 
void db_attribute_copy (Db *db, int iatt_in, int iatt_out)
 
void db_attribute_init (Db *db, int ncol, int iatt, double valinit)
 
void db_attribute_del_mult (Db *db, int i_del, int n_del)
 
int db_grid_copy_params (DbGrid *dbin, int mode, DbGrid *dbout)
 
double db_grid_maille (Db *db)
 
int db_gradient_update (Db *db)
 
int db_selref (int ndim, int *nx, int *ref, double *tabin, double *tabout)
 
int db_locate_in_grid (DbGrid *db_grid, double *coor)
 
int db_grid_match (DbGrid *db1, DbGrid *db2)
 
int db_locator_attribute_add (Db *db, const ELoc &locatorType, int number, int r_tem, double valinit, int *iptr)
 
int db_grid_copy (DbGrid *db1, DbGrid *db2, int *ind1, int *ind2, int ncol, int *cols)
 
int db_grid_copy_dilate (DbGrid *db1, int iatt1, DbGrid *db2, int iatt2, int mode, int *nshift)
 
void grid_to_point (const DbGrid *db, int *indg, double *percent, double *coor)
 
int point_to_point (Db *db, double *coor)
 
int point_to_grid (const DbGrid *db, const double *coor, int flag_outside, int *indg)
 
int point_to_bench (const DbGrid *db, double *coor, int flag_outside, int *indb)
 
int index_point_to_grid (const Db *dbin, int iech, int flag_outside, const DbGrid *dbout, double *coor)
 
int point_inside_grid (Db *db, int iech, const DbGrid *dbgrid)
 
void db_monostat (Db *db, int iatt, double *wtot, double *mean, double *var, double *mini, double *maxi)
 
int db_proportion (Db *db, DbGrid *dbgrid, int nfac1max, int nfac2max, int *nclout)
 
int db_merge (Db *db, int ncol, int *cols)
 
int db_count_defined (Db *db, int icol)
 
void db_locators_correct (VectorString &strings, const VectorInt &current, int flag_locnew)
 
int db_prop_read (DbGrid *db, int ix, int iy, double *props)
 
int db_prop_write (DbGrid *db, int ix, int iy, double *props)
 
double * db_distances_general (Db *db1, Db *db2, int niso, int mode, int flag_same, int *n1, int *n2, double *dmin, double *dmax)
 
int db_is_isotropic (const Db *db, int iech, double *data)
 
int is_grid_multiple (DbGrid *db1, DbGrid *db2)
 
DbGriddb_create_grid_multiple (DbGrid *dbin, const VectorInt &nmult, int flag_add_rank)
 
DbGriddb_create_grid_divider (DbGrid *dbin, const VectorInt &nmult, int flag_add_rank)
 
DbGriddb_create_grid_dilate (DbGrid *dbin, int mode, const VectorInt &nshift, int flag_add_rank)
 
int db_gradient_modang_to_component (Db *db, int ang_conv, int iad_mod, int iad_ang, int iad_gx, int iad_gy)
 
int db_gradient_component_to_modang (Db *db, int verbose, int iad_gx, int iad_gy, int iad_mod, int iad_ang, double scale, double ve)
 
int db_get_rank_absolute_to_relative (Db *db, int iech0)
 
int db_get_rank_relative_to_absolute (Db *db, int iech0)
 
double get_grid_value (DbGrid *dbgrid, int iptr, int *indg, int ix, int iy, int iz)
 
void set_grid_value (DbGrid *dbgrid, int iptr, int *indg, int ix, int iy, int iz, double value)
 
DbGriddb_grid_reduce (DbGrid *db_grid, int iptr, int *margin, int *limmin, int flag_sel, int flag_copy, int verbose, double vmin, double vmax)
 
int db_grid_patch (DbGrid *ss_grid, DbGrid *db_grid, int iptr_ss, int iptr_db, int iptr_rank, int new_rank, int oper, int verbose)
 
int db_name_identify (Db *db, const String &string)
 
void db_extension_rotated (Db *db, double *rotmat, VectorDouble &mini, VectorDouble &maxi)
 
VectorDouble db_get_grid_axis (DbGrid *dbgrid, int idim)
 
VectorDouble db_get_attribute (Db *db, int iatt, bool verbose)
 
VectorInt db_identify_variables_by_name (Db *db, const String &pattern)
 
void grid_iterator_init (Grid *grid, const VectorInt &order)
 
VectorInt grid_iterator_next (Grid *grid)
 

Function Documentation

double bench_distance ( const Db db,
int  iech1,
int  iech2 
)

Calculate the bench separation for the current pair

Returns
Bench separation;
0 if space dimension < 3 or TEST if a coordinate is underfined
Parameters
[in]dbDb structure
[in]iech1Rank of the first sample
[in]iech2Rank of the second sample
Remarks
The bench criterion consists in comparing the difference of
according to the 3rd coordinate with the bench width.
int compat_NDIM ( Db db1,
Db db2 
)

Checks if Space Dimension of the first Db is at least equal to the Space dimension of the second Db

Returns
Error return code (1 for correct and 0 otherwise).
If an error is found, a message is issued
Parameters
[in]db1first Db descriptor (usually dbin)
[in]db2second Db descriptor (usually dbout)
Remarks
This function checks that the we can perform an operation
(i.e. migration) of a 2D data set onto a 3D one.
The opposite is not correct.
double cylinder_radius ( const Db db,
int  iech1,
int  iech2,
const VectorDouble codir 
)

Calculate the cylinder radius along a calculation direction

Returns
Cylinder radius (or TEST if a coordinate is unknown)
Parameters
[in]dbDb structure
[in]iech1Rank of the first sample
[in]iech2Rank of the second sample
[in]codirDirection coefficient
void db_attribute_copy ( Db db,
int  iatt_in,
int  iatt_out 
)

Copy an attribute into another one

Parameters
[in]dbDb structure
[in]iatt_inInput attribute
[in]iatt_outOutput attribute
Remarks
The output attribute must already be allocated
void db_attribute_del_mult ( Db db,
int  i_del,
int  n_del 
)

Remove a set of "n_del" attributes starting from "i_del"

Parameters
[in]dbDb structure
[in]i_delRank of the first attribute to be deleted
[in]n_delNumber of attributes to be deleted
int db_attribute_identify ( const Db db,
const ELoc &  locatorType,
int  item 
)

Returns the rank of the attribute in the array

Returns
Rank of the attribute
Parameters
[in]dbDb descriptor
[in]locatorTypeRank of the pointer
[in]itemRank of the attribute in the pointer
void db_attribute_init ( Db db,
int  ncol,
int  iatt,
double  valinit 
)

Initialize a variable with the given argument (given by attribute)

Parameters
[in]dbDb structure
[in]ncolNumber of attributes to be initialized
[in]iattRank of the first variable to be initialized
[in]valinitValue set to the variable
int db_attribute_range ( const Db db,
int  iatt,
double *  mini,
double *  maxi,
double *  delta 
)

Returns the range for a variable

Returns
Error return code
Parameters
[in]dbDb structure
[in]iattRank of the target attribute
[out]miniMinimum
[out]maxiMaximum
[out]deltaExtension
int db_center ( Db db,
double *  center 
)

Returns the center of a data set

Parameters
[in]dbDb structure
[out]centerArray containing the coordinates of the center (Dimension = get_NDIM(db))
int db_coorvec_get ( const Db db,
int  idim,
double *  tab 
)

Read the vector of a given coordinate from the Db structure into the array tab()

Returns
Error return code
Parameters
[in]dbDb descriptor
[in]idimSpace dimension
[out]tabArray of values

This method is not documented on purpose. It should remain private

int db_coorvec_put ( Db db,
int  idim,
double *  tab 
)

Write the array tab() into a vector of coordinates of the Db structure

Returns
Error return code
Parameters
[in]dbDb descriptor
[in]idimSpace dimension
[in]tabArray of values

This method is not documented on purpose. It should remain private

int db_count_defined ( Db db,
int  icol 
)

Count the number of defined values for a Column

Returns
Number of defined values
Parameters
[in]dbDb structure
[in]icolRank of the Column
Db* db_create_from_target ( const double *  target,
int  ndim,
int  flag_add_rank 
)

Create a Db containing a single target

Returns
Pointer to the newly created Db point structure
Parameters
[in]targetArray containing the target coordinates
[in]ndimSpace dimension
[in]flag_add_rank1 to add the 'rank' as first column
DbGrid* db_create_grid_dilate ( DbGrid dbin,
int  mode,
const VectorInt nshift,
int  flag_add_rank 
)

Create a Grid Db extended (or compressed) from another Grid Db

Returns
Pointer to the newly created Db grid structure
Parameters
[in]dbinInitial Db Grid
[in]mode1 for extending; -1 for compressing
[in]nshiftArray of shifts
[in]flag_add_rank1 to add the 'rank' as first column
DbGrid* db_create_grid_divider ( DbGrid dbin,
const VectorInt nmult,
int  flag_add_rank 
)

Create a Grid Db as a divider of another Grid Db

Returns
Pointer to the newly created Db grid structure
Parameters
[in]dbinInitial Db Grid
[in]nmultArray of subdivision coefficients
[in]flag_add_rank1 to add the 'rank' as first column
DbGrid* db_create_grid_multiple ( DbGrid dbin,
const VectorInt nmult,
int  flag_add_rank 
)

Create a Grid Db as a multiple of another Grid Db

Returns
Pointer to the newly created Db grid structure
Parameters
[in]dbinInitial Db Grid
[in]nmultArray of multiplicity coefficients
[in]flag_add_rank1 to add the 'rank' as first column **
double* db_distances_general ( Db db1,
Db db2,
int  niso,
int  mode,
int  flag_same,
int *  n1,
int *  n2,
double *  dmin,
double *  dmax 
)

Evaluate the array of distances between samples of two data sets Takes the selection into account (if any)

Returns
Array of distances
Parameters
[in]db1Db first descriptor
[in]db2Db second descriptor
[in]nisoNumber of variables tested for isotopy
[in]modeType of array returned 0 : extreme distances 1 : the distance to the closest sample 2 : all point-to-point distances
[in]flag_same1 if both Db coincide
[out]n1First dimension of the returned array
[out]n2Second dimension of the returned array
[out]dminMinimum distance
[out]dmaxMaximum distance
Remarks
The returned array must be freed by calling routine
When the two Dbs coincide, the distance calculation excludes
the comparison between one sample and itself
double db_epsilon_distance ( Db db)

Returns the epsilon value calculated from the extension of the field

Returns
Epsilon value
Parameters
[in]dbDb structure
void db_extension ( const Db db,
VectorDouble mini,
VectorDouble maxi,
bool  flag_preserve 
)

Returns the extension of the field along each axis This calculation takes contents of arguments at input into account if 'flag_preserve' is true

Parameters
[in]dbDb structure
[out]miniArray containing the minimum (Dimension = ndim)
[out]maxiArray containing the maximum (Dimension = ndim)
[in]flag_preserveFalse Contents of arguments at input is preserved
Remarks
If the contents of an item of the arguments is TEST, this value
is not used in the comparison
int db_extension_diag ( const Db db,
double *  diag 
)

Returns the extension of the diagonal of the field

Returns
Error return code
Parameters
[in]dbDb structure
[out]diagDimension of the field diagonal
Remarks
Different versions are provided for Euclidean and Spherical cases
void db_extension_rotated ( Db db,
double *  rotmat,
VectorDouble mini,
VectorDouble maxi 
)

Returns the extension of the field (after rotation) along each axis

Parameters
[in]dbDb structure
[in]rotmatRotation matrix (optional)
[out]miniArray containing the minimum (Dimension = ndim)
[out]maxiArray containing the maximum (Dimension = ndim)
Remarks
This function does nothing if:
- no rotation matrix is defined
- space dimension is 1 or larger than 3
VectorDouble db_get_attribute ( Db db,
int  iatt,
bool  verbose 
)

Returns a vector containing an attribute from the Db

Parameters
[in]dbDb structure
[in]iattAttribute rank
[in]verboseVerbose flag
VectorDouble db_get_grid_axis ( DbGrid dbgrid,
int  idim 
)

Returns a vector containing the coordinates of a Grid along one space dimension

Parameters
[in]dbgridDb structure
[in]idimRank of the space dimension
int db_get_rank_absolute_to_relative ( Db db,
int  iech0 
)

Returns the relative rank of a sample from its absolute rank These are different due to the presence of a selection Returns -1 if not found

Returns
Relative rank of a sample
Parameters
[in]dbDb structure
[in]iech0Absolute sample rank
int db_get_rank_relative_to_absolute ( Db db,
int  iech0 
)

Returns the absolute rank of a sample from its relative rank These are different due to the presence of a selection Returns -1 if not found

Returns
Relative rank of a sample
Parameters
[in]dbDb structure
[in]iech0Relative sample rank
int db_gradient_component_to_modang ( Db db,
int  verbose,
int  iad_gx,
int  iad_gy,
int  iad_mod,
int  iad_ang,
double  scale,
double  ve 
)

Transform a set of gradients defined by (gx,gy) into (module,angle) Only defined in the 2-D case

Returns
Error return code
Parameters
[in]dbInitial Db
[in]verbose1 for the verbose option
[in]iad_gxRank of the 'gx' attribute (defined in degrees)
[in]iad_gyRank of the 'gy' attribute (defined in degrees)
[in]iad_modRank of the 'modulus' attribute
[in]iad_angRank of the 'angle' attribute (defined in degrees)
[in]scaleScaling factor for the modulus
[in]veModeration factor
Remarks
Attributes 'gx' and 'gy' may coincide with 'modulus' and 'angle'
Nothing is done (more than the conversion if scale=1 and ve=0)
int db_gradient_modang_to_component ( Db db,
int  ang_conv,
int  iad_mod,
int  iad_ang,
int  iad_gx,
int  iad_gy 
)

Transform a set of gradients defined by (modulus,angle) into (gx,gy) Only defined in the 2-D case

Returns
Error return code
Parameters
[in]dbInitial Db
[in]ang_convConvention on the angles
  • 1: Trigonometry (From East counter-clockwise)
  • 2: From North clockwise
[in]iad_modRank of the 'modulus' attribute
[in]iad_angRank of the 'angle' attribute (defined in degrees)
[in]iad_gxRank of the 'gx' attribute (defined in degrees)
[in]iad_gyRank of the 'gy' attribute (defined in degrees)
Remarks
Attributes 'gx' and 'gy' may coincide with 'modulus' and 'angle'
int db_gradient_update ( Db db)

Update the Data Base for Kriging with Gradient components This update is limited to the 2-D Monovariate case

Returns
Error return code
Parameters
[in]dbInput/output Db
Remarks
In the case of Kriging with Gradient, the gradient components
are transformed into additional variables
int db_grid_copy ( DbGrid db1,
DbGrid db2,
int *  ind1,
int *  ind2,
int  ncol,
int *  cols 
)

Copy a set of variables from a grid Db to another grid Db

Returns
Error return code
Parameters
[in]db1Input Grid Db structure
[in]db2Output Grid Db structure
[in]ind1Vector of indices in the first Db
[in]ind2Vector of indices in the second Db
[in]ncolNumber of variables to be copied
[in]colsArray of input variable columns
int db_grid_copy_dilate ( DbGrid db1,
int  iatt1,
DbGrid db2,
int  iatt2,
int  mode,
int *  nshift 
)

Copy one variable from a grid Db to another grid Db

Returns
Error return code
Parameters
[in]db1Input Grid Db structure
[in]iatt1Rank of the attribute in Db1
[in]db2Output Grid Db structure
[in]iatt2Rank of the attribute in Db2
[in]mode1 for dilation; -1 for compression
[in]nshiftVector of dilation/compression defined in cell number along each space direction
int db_grid_copy_params ( DbGrid dbin,
int  mode,
DbGrid dbout 
)

Copy Grid characteristics

Returns
Error return code
Parameters
[in]dbinInput Grid Db structure
[in]modeType of parameters that must be copied
[out]dboutOutput Grid Db structure
int db_grid_define_coordinates ( DbGrid db)

Define the coordinates in a Grid structure

Returns
Error return code
Parameters
[in]dbThe Db structure
Remarks
This function considers the grid characteristics and updates
the locators dedicated to coordinates
This makes sense when a new grid is generated or when the grid
characteristics have changed
double db_grid_maille ( Db db)

Calculate the surface/volume mesh of the grid

Returns
Mesh value
Parameters
[in]dbDb structure
int db_grid_match ( DbGrid db1,
DbGrid db2 
)

Check if two grid match

Returns
1 if the two grid match; 0 otherwise
Parameters
[in]db1Db1 grid structure
[in]db2Db1 grid structure
Remarks
The grid must match up to their minimum space dimension
The test is only performed on the geometry characteristics
The test returns 0 if one of the two file is not a grid
int db_grid_patch ( DbGrid ss_grid,
DbGrid db_grid,
int  iptr_ss,
int  iptr_db,
int  iptr_rank,
int  new_rank,
int  oper,
int  verbose 
)

Patch a sub-grid within a main grid

Returns
Error return code
Parameters
[in]ss_gridDb sub-grid structure
[in]db_gridDb main grid structure
[in]iptr_ssRank of the attribute in the sub-grid
[in]iptr_dbRank of the attribute in the main grid
[in]iptr_rankRank of the attribute storing object rank If <0, no check is performed: always patch
[in]new_rankRank of the current object to patch in main grid
[in]oper>0 for larger; <0 for smaller
[in]verboseVerbose flag
Remarks
When 'iptr_rank' is defined (>=0), defined pixels of the current
sub-grid overwrites the corresponding pixel within the main grid
only if its rank ('new_rank') is larger (oper>0) or smaller
(oper<0)) than the rank of the same pixel in the main grid
(attribute 'iptr_rank')
When 'iptr_rank' is undefined, arguments 'new_rank', 'oper' are
useless
void db_grid_print ( Db db)

Print the Summary of the Grid structure

Parameters
[in]dbPointer to the Db structure (organized as a grid)
DbGrid* db_grid_reduce ( DbGrid db_grid,
int  iptr,
int *  margin,
int *  limmin,
int  flag_sel,
int  flag_copy,
int  verbose,
double  vmin,
double  vmax 
)

Extract the subgrid (from a grid) which contains the only cells where the target variable lies wuthin the target interval Selection in the input grid is taken into account

Parameters
[in]db_gridDb structure
[in]iptrRank of the column of the target variable
[in]marginArray of margins (or NULL)
[in]limminArray of minimum dimensions (or NULL)
[in]flag_selCreate the selection
[in]flag_copy1 if the selection must be copied in sub-grid
[in]verboseVerbose flag
[in]vminLower bound (included)
[in]vmaxUpper bound (excluded)
VectorInt db_identify_variables_by_name ( Db db,
const String pattern 
)

Identify the variables of a Db where names match a criterion

Parameters
[in]dbDb structure
[in]patternMatching pattern
int db_index_grid_to_sample ( const DbGrid db,
const int *  indg 
)

Converts from grid indices to the absolute address

Returns
Absolute address in the grid descriptor
Parameters
[in]dbdescriptor of the grid parameters
[in]indgarray of grid indices
Remarks
If one grid index does not lie within the grid, -1 is returned
void db_index_sample_to_grid ( const DbGrid db,
int  iech,
int *  indg 
)

Converts from sample index into grid indices

Parameters
[in]dbDb structure
[in]iechRank of the sample
[out]indgGrid indices
int db_index_sorted_in_grid ( const DbGrid db,
int  iech,
int *  indg 
)

Return the index of the ordered grid sample (see remarks)

Returns
Rank of the ordered sample
Parameters
[in]dbDb structure
[in]iechRank of the sample
[out]indgArray used for sorting grid indices
Remarks
The grid samples are ordered if they are reviewed in such an order
which minimizes the distance between any pair of successive indices
int* db_indg_alloc ( const Db db)

Allocates an array for the storage of grid indices

Returns
A pointer to the allocated array
Parameters
[in]dbDb descriptor
Remarks
The allocated array must be freed using db_indg_free
A fatal error occurs if the core allocation fails.
int* db_indg_free ( int *  indice)

Frees an array for the storage of grid indices

Returns
A pointer to the newly freed array
Parameters
[in]indiceArray to be freed
int db_is_isotropic ( const Db db,
int  iech,
double *  data 
)

Check if a sample corresponding to a given rank is isotropic or not

Returns
1 if all variables are defined (isotropic) or 0 otherwise
Parameters
[in]dbDb descriptor
[in]iechRank of the target sample
[out]dataIf the output vector is provided. Returns the data value at target sample as a vector
Remarks
If the sample is masked off, the function returns 0
int db_locate_in_grid ( DbGrid db_grid,
double *  coor 
)

Converts from coordinates sample index into grid and absolute indices

Returns
Absolute grid index (starting from 0) or -1 if outside the grid
Parameters
[in]db_gridDb grid structure
[in]coorArray containing the coordinates of the sample
int db_locator_attribute_add ( Db db,
const ELoc &  locatorType,
int  number,
int  r_tem,
double  valinit,
int *  iptr 
)

Add and initiate several attributes corresponding to a given locator

Returns
Error return code
Parameters
[in]dbDb structure
[in]locatorTypeRank of the Pointer (ELoc)
[in]numberNumber of locators to be defined
[in]r_temRank of the first item in the pointer
[in]valinitValue to be used for initialization
[out]iptrRank of the first new attribute
void db_locators_correct ( VectorString strings,
const VectorInt current,
int  flag_locnew 
)

Define the array of locators

Parameters
[in]stringsArray of locators
[in]currentArray of ranks of the last modified locator
[in]flag_locnewReset all locators
Remarks
The elements of the array current are numbered starting from 1
int db_merge ( Db db,
int  ncol,
int *  cols 
)

Merge a set of variables in a Db

Returns
Error return code
Parameters
[in]dbDb structure
[in]ncolNumber of variables to be merged
[in]colsArray of input variable columns
void db_monostat ( Db db,
int  iatt,
double *  wtot,
double *  mean,
double *  var,
double *  mini,
double *  maxi 
)

Monovariate statistics

Parameters
[in]dbDb structure
[in]iattRank of the attribute
[out]wtotSum of the weights
[out]meanMean of the variable
[out]varvariance of the variable
[out]miniMinimum value
[out]maxiMaximum value
String db_name_get_by_att ( const Db db,
int  iatt 
)

Returns the name assigned to the given attribute

Returns
Error return code
Parameters
[in]dbDb structure
[in]iattRank of the attribute (starting at 0)
String db_name_get_by_col ( Db db,
int  icol 
)

Returns the name assigned to the given column

Returns
Error return code
Parameters
[in]dbDb structure
[in]icolRank of the column (starting at 0)
int db_name_identify ( Db db,
const String string 
)

Identify the attribute by its name

Returns
Rank of the variable starting from 0 (or -1 if not found)
Parameters
[in]dbDb descriptor
[in]stringattribute name
int db_name_set ( Db db,
int  iatt,
const String name 
)

Define the name assigned to the given attribute

Returns
Error return code
Parameters
[in]dbDb structure
[in]iattRank of the attribute (starting at 0)
[in]nameName assigned to the current attribute
int db_prop_read ( DbGrid db,
int  ix,
int  iy,
double *  props 
)

Read the proportions per VPC

Returns
Error return code
Parameters
[in]dbDb structure
[in]ixRank of the cell along X
[in]iyRank of the cell along Y
[out]propsArray of proportions
Remarks
This procedure is meant for a 3-D grid file
int db_prop_write ( DbGrid db,
int  ix,
int  iy,
double *  props 
)

Write the proportions (per VPC)

Returns
Error return code
Parameters
[in]dbDb structure
[in]ixRank of the cell along X
[in]iyRank of the cell along Y
[in]propsArray of proportions
Remarks
This procedure is meant for a 3-D grid file
int db_proportion ( Db db,
DbGrid dbgrid,
int  nfac1max,
int  nfac2max,
int *  nclout 
)

Calculates the proportions of facies within a grid

Returns
Error return code
Parameters
[in]dbInput Db structure
[in]dbgridOutput Grid Db structure
[in]nfac1maxMaximum number of facies for the first variable
[in]nfac2maxMaximum number of facies for the second variable
[out]ncloutTotal number of classes
Remarks
This procedure is designed for one or two Z-variables
When used for 2 variables, the proportions are for pairs of
variables
double* db_sample_alloc ( const Db db,
const ELoc &  locatorType 
)

Allocates the array for storing a sample

Returns
A pointer to the allocated array
Parameters
[in]dbDb descriptor
[in]locatorTypevector type (ELoc)
Remarks
The allocated array must be freed using db_sample_free()
A fatal error occurs if the core allocation fails.
double* db_sample_free ( double *  tab)

Frees the array for storing a sample

Returns
A pointer to the array to be freed
Parameters
[in]tabSample array to be freed
int db_sample_get_att ( Db db,
int  iech,
int  number,
int  iatt,
double *  tab 
)

Loads the contents of several (consecutive) attributes for a sample

Returns
1 if the values contain at least one TEST value
Parameters
[in]dbDb descriptor
[in]iechRank of the sample
[in]numberNumber of columns
[in]iattRank of the starting attribute
[out]tabArray of values
int db_sample_load ( Db db,
const ELoc &  locatorType,
int  iech,
double *  tab 
)

Loads the sample from a Db structure

Returns
Error return code
Parameters
[in]dbDb descriptor
[in]locatorTypevector type (ELoc)
[in]iechnumber of the sample
[out]tabarray of values

This method is not documented on purpose. It should remain private

void db_sample_print ( Db db,
int  iech,
int  flag_ndim,
int  flag_nvar,
int  flag_nerr 
)

Print a sample

Parameters
[in]dbDb structure
[in]iechRank of the sample
[in]flag_ndim1 if the coordinates must be printed
[in]flag_nvar1 if the variables must be printed
[in]flag_nerr1 if the error measurement variance must be printed
void db_sample_put_att ( Db db,
int  iech,
int  number,
int  iatt,
double *  tab 
)

Saves the contents of several (consecutive) attributes for a sample

Parameters
[in]dbDb descriptor
[in]iechRank of the sample
[in]numberNumber of columns
[in]iattRank of the starting attribute
[in]tabarray of values
int db_selection_get ( const Db db,
int  item,
double *  tab 
)

Read a vector from the Db structure into the array tab() for selection

Returns
Error return code
Parameters
[in]dbDb descriptor
[in]itemRank of the item in the pointer
[out]tabArray of values
int db_selref ( int  ndim,
int *  nx,
int *  ref,
double *  tabin,
double *  tabout 
)

Select a 2-D grid from a Grid Db

Returns
Error returned code
Parameters
[in]ndimSpace dimension of the Db
[in]nxNumber of meshes of the grid
[in]refArray giving the indices of the reference planes
  • Grid indices are counted starting from 1
  • -1 for the directions of interest
[in]tabinInput array
[out]taboutOutput array
double* db_vector_alloc ( const Db db)

Allocates the array for storing a column of the Db

Returns
A pointer to the allocated array
Parameters
[in]dbDb descriptor
Remarks
The allocated array must be freed using db_vector_free()
A fatal error occurs if the core allocation fails.
double* db_vector_free ( double *  tab)

Frees the array for storing a vector

Returns
A pointer to the array to be freed
Parameters
[in]tabVector array to be freed
int db_vector_get ( Db db,
const ELoc &  locatorType,
int  item,
double *  tab 
)

Read a vector from the Db structure into the array tab()

Returns
Error return code
Parameters
[in]dbDb descriptor
[in]locatorTypeRank of the pointer (ELoc)
[in]itemRank of the item in the pointer
[out]tabArray of values
int db_vector_get_att ( const Db db,
int  iatt,
double *  tab 
)

Read a vector from the Db structure into the array tab() The identification is done by Attribute

Returns
Error return code
Parameters
[in]dbDb structure
[in]iattRank of the Attribute
[out]tabArray of values
int db_vector_get_att_sel ( Db db,
int  iatt,
double *  tab 
)

Read a vector from the Db structure into the array tab() through selection The identification is done by Attribute

Returns
Error return code
Parameters
[in]dbDb structure
[in]iattRank of the Attribute
[out]tabArray of values
Remarks
If a selection is defined, the masked samples are set to TEST
int db_vector_get_att_sel_compress ( Db db,
int  iatt,
int *  number,
double *  tab 
)

Read a vector from the Db structure into the array tab() If a selection is preset, the returned array is compressed

Returns
Error return code
Parameters
[in]dbDb structure
[in]iattRank of the attribute
[out]tabArray of returned values
[out]numberNumber of returned values
int db_vector_put ( Db db,
const ELoc &  locatorType,
int  locatorIndex,
double *  tab 
)

Write the array tab() into a vector of the Db structure

Parameters
[in]dbDb descriptor
[in]locatorTypeRank of the pointer (ELoc)
[in]locatorIndexRank of the item in the pointer (starting from 0)
[in]tabArray of values
double distance_grid ( DbGrid db,
int  flag_moins1,
int  iech1,
int  iech2,
double *  dist_vect 
)

Calculates the distance between two points in the same grid Db

Returns
The calculated distance
Parameters
[in]dbDb structure
[in]flag_moins11 to use the cell center
[in]iech1rank of the first sample
[in]iech2rank of the second sample
[out]dist_vectIf the output vector is provided. Returns the distance as a vector
double distance_inter ( const Db db1,
const Db db2,
int  iech1,
int  iech2,
double *  dist_vect 
)

Calculates the distance between two points

Returns
The calculated distance or TEST if one coordinate not defined
Parameters
[in]db1Db structure for the first sample
[in]db2Db structure for the second sample
[in]iech1rank of the first sample
[in]iech2rank of the second sample
[out]dist_vectIf the output vector is provided. Returns the distance as a vector
Remarks
: If both Data Bases do not share the same Space Dimension
: the test is performed on their minimum.
: The returned array 'vect' must be dimension to that value
double distance_intra ( const Db db,
int  iech1,
int  iech2,
double *  dist_vect 
)

Calculates the distance between two points in the same Db

Returns
The calculated distance or TEST if one coordinate not defined
Parameters
[in]dbDb structure
[in]iech1rank of the first sample
[in]iech2rank of the second sample
[out]dist_vectIf the output vector is provided. Returns the distance as a vector
int exist_LOCATOR ( Db db,
const ELoc &  locatorType 
)

Checks the presence of at least one item for a given locator in the Db

Returns
1 if at least one item has been found and 0 otherwise
Parameters
[in]dbDb descriptor
[in]locatorTypeRank of the pointer (ELoc)
double get_grid_value ( DbGrid dbgrid,
int  iptr,
int *  indg,
int  ix,
int  iy,
int  iz 
)

Returns a value from the a 3-D (maximum) grid

Returns
Returned value
Parameters
[in]dbgridDb Grid structure
[in]iptrRank of the column
[in]indgWorking index array (Dimension: get_NDIM(dbgrid))
[in]ixRank of the node along first dimension
[in]iyRank of the node along second dimension
[in]izRank of the node along third dimension
double get_LOCATOR_ITEM ( Db db,
const ELoc &  locatorType,
int  item,
int  iech 
)

Reads one item of a given locator from Db

Returns
Returned value
Parameters
[in]dbDb structure
[in]locatorTypeRank of the pointer (ELoc)
[in]itemRank of the item in the pointer
[in]iechRank of the sample
Remarks
For efficiency reason, argument validity is not tested
int get_LOCATOR_NITEM ( const Db db,
const ELoc &  locatorType 
)

Returns the number of items for a given locator in the Db

Returns
Number of items
Parameters
[in]dbDb descriptor
[in]locatorTypeRank of the pointer (ELoc)
void grid_iterator_init ( Grid grid,
const VectorInt order 
)

Initialize the Grid iterator

VectorInt grid_iterator_next ( Grid grid)

Returns 1 when the last element of the iteration is reached

Increment the Grid iterator

void grid_to_point ( const DbGrid db,
int *  indg,
double *  percent,
double *  coor 
)

Converts from grid indices and percentages to the point absolute coordinates

Parameters
[in]dbdescriptor of the grid parameters
[in]indgarray of indices of the grid
[in]percentarray of grid percentages (NULL if absent)
[out]coorcoordinates of the point
int index_point_to_grid ( const Db dbin,
int  iech,
int  flag_outside,
const DbGrid dbout,
double *  coor 
)

Find the index of the output grid file which is the closest to the sample of the input file

Returns
Error return code
>= index of the grid node
-1 if the point is outside the grid
Parameters
[in]dbindescriptor of the input file
[in]iechIndex of the data point
[in]flag_outsidevalue returned for the point outside the grid
  • 1 the index is set to the closest grid node
  • 0 the index is set to -1
  • -1 do not correct the index
[in]dboutdescriptor of the output grid file
[out]coorWorking array (dimension: ndim)
int is_grid_multiple ( DbGrid db1,
DbGrid db2 
)

Check if a grid is a multiple of the other grid

Returns
1 if the two grid are multiple; 0 otherwise
Parameters
[in]db1Db1 small grid structure
[in]db2Db1 coarse grid structure
int point_inside_grid ( Db db,
int  iech,
const DbGrid dbgrid 
)

Check if a sample of a Db lies within a Grid Db

Returns
1 if the point lies within the grid; 0 otherwise
Parameters
[in]dbDb structure
[in]iechRank of the target sample
[in]dbgridGrid Db structure
int point_to_bench ( const DbGrid db,
double *  coor,
int  flag_outside,
int *  indb 
)

Converts from point coordinates to index of the bench to which it belongs

Returns
Error return code
0 if the point is inside the grid
1 if the point is outside the grid
-1 if one coordinate is undefined
-2 if the grid is defined in space less than 3D
Parameters
[in]dbdescriptor of the grid parameters
[in]coorarray of coordinates of the point
[in]flag_outsidevalue returned for the point outside the grid
  • 1 the index is set to the closest grid node
  • 0 the index is set to -1
  • -1 do not correct the index
[out]indbindex of the bench
Remarks
The bench corresponds to the third dimension of the grid provided
as reference
int point_to_grid ( const DbGrid db,
const double *  coor,
int  flag_outside,
int *  indg 
)

Converts from point coordinates to nearest grid node indices

Returns
Error return code
0 if the point is inside the grid
1 if the point is outside the grid
-1 if one coordinate is undefined
Parameters
[in]dbdescriptor of the grid parameters
[in]coorarray of coordinates of the point
[in]flag_outsidevalue returned for the point outside the grid
  • 1 the index is set to the closest grid node
  • 0 the index is set to -1
  • -1 do not correct the index
[out]indgindices of the closest grid node
int point_to_point ( Db db,
double *  coor 
)

Returns the rank of the closest isolated point

Returns
Output index
Parameters
[in]dbdescriptor of the Db
[in]coorarray of coordinates of the point
void set_grid_value ( DbGrid dbgrid,
int  iptr,
int *  indg,
int  ix,
int  iy,
int  iz,
double  value 
)

Set the value in the a 3-D (maximum) grid

Parameters
[in]dbgridDb Grid structure
[in]iptrRank of the column
[in]indgWorking index array (Dimension: get_NDIM(dbgrid))
[in]ixRank of the node along first dimension
[in]iyRank of the node along second dimension
[in]izRank of the node along third dimension
[in]valueAssigned value
void set_LOCATOR_ITEM ( Db db,
const ELoc &  locatorType,
int  item,
int  iech,
double  value 
)