1.8.0
CCC
 
Loading...
Searching...
No Matches
gstlrn::Db Class Reference

Class containing the Data Information. More...

#include <Db.hpp>

Inheritance diagram for gstlrn::Db:
gstlrn::AStringable gstlrn::ASerializable gstlrn::ICloneable gstlrn::DbGraphO gstlrn::DbGrid gstlrn::DbLine gstlrn::DbMeshStandard gstlrn::DbMeshTurbo

Detailed Description

Class containing the Data Information.

This Data Set benefits from the comparison to an Excel spread sheet: it can be considered as a Data Frame with a number of rows and a number of columns. The columns will correspond to variables and the rows to samples.

Notes:

  • For short, this Data Base organization is referred to as Db,
  • At any time, variables can be added, renamed or deleted,
  • In the current version, this Data Set is currently limited to numerical contents. The data frame is necessarily completely filled with values: therefore, a specific value stands for a missing value (printed as NA);

Moreover each variable may be assigned a role (or functionality) in the rest of a script. This role is defined by a locator: for example, a variable can serve as a coordinate, or a target variable. The locators can be viewed in the following list (see ELoc.hpp). Note that a variable which does not play any role in particular may be assigned to an idle role (locator NA); This locator may be modified or cancelled (by the user) at any time.

There are two status for these locators: unique or multiple.

Unique. Only one variable can be assigned this unique locator: this is the case for the selection (SEL) as there may be only one current selection activated at a time.

Multiple. Several variable may be assigned the same locator: this is the case for the coordinates (X). In that case, the locator name is followed by its rank (1-based). Then the first coordinate will correspond to the locator X1, the second coordinate to X2, ... Note that:

  • for a given locator name, the ranks are always consecutive between 1 and N (if it happens that you delete X3, the locator X4 is automatically modified into X3, X5 into X4, and so on up to X{N} into X{N-1}.
  • there is no limitation in the number of ranks for a given locator name.

Each variable (or column) can be designated:

  • by its name (unique in the Data Base) or
  • by its locator (name and rank) or
  • by its column index (0-based): this designation mode is dangerous (and not recommended) as the index may change over time.

Public Member Functions

 Db ()
 
 Db (const Db &r)
 
Dboperator= (const Db &r)
 
virtual ~Db ()
 
String toString (const AStringFormat *strfmt=nullptr) const override
 ICloneable interface.
 
virtual bool isGrid () const
 Interface for Db.
 
virtual bool isLine () const
 
virtual bool isMesh () const
 
virtual double getCoordinate (Id iech, Id idim, bool flag_rotate=true) const
 
virtual void getCoordinatesInPlace (1 &coor, Id iech, bool flag_rotate=true) const
 Update the vector of coordinates (optimized manner) No check is done with respect to the dimension of the returned vector.
 
virtual double getUnit (Id idim=0) const
 
virtual Id getNDim () const
 
virtual bool mayChangeSampleNumber () const
 
virtual void resetDims (Id ncol, Id nech)
 
virtual bool isConsistent () const
 
Id resetFromSamples (Id nech, const ELoadBy &order=ELoadBy::fromKey("SAMPLE"), const 1 &tab=1(), const VectorString &names=VectorString(), const VectorString &locatorNames=VectorString(), bool flagAddSampleRank=true)
 
Id resetFromCSV (const String &filename, bool verbose, const CSVformat &csvfmt, Id ncol_max=-1, Id nrow_max=-1, bool flagAddSampleRank=true)
 
Id resetFromBox (Id nech, const 1 &coormin, const 1 &coormax, Id ndim=2, double extend=0., Id seed=321415, bool flagAddSampleRank=true)
 
Id resetFromOnePoint (const 1 &tab=1(), bool flagAddSampleRank=true)
 
Id resetSamplingDb (const Db *dbin, double proportion=0, Id number=0, const VectorString &names=VectorString(), Id seed=23241, bool verbose=false, bool flagAddSampleRank=true)
 
Id resetReduce (const Db *dbin, const VectorString &names=VectorString(), const 1 &ranks=1(), bool verbose=false)
 
Id resetFromGridRandomized (const DbGrid *dbin, double randperc=0., bool flagAddSampleRank=true)
 
const std::vector< double > & getArrays () const
 
String getNameByLocator (const ELoc &locatorType, Id locatorIndex=0) const
 
String getNameByColIdx (Id icol) const
 
String getNameByUID (Id iuid) const
 
virtual void initThread () const
 
VectorString getName (const String &name) const
 
VectorString getNames (const VectorString &names) const
 
VectorString getNamesByLocator (const ELoc &locatorType) const
 
VectorString getNamesByColIdx (const 1 &icols) const
 
VectorString getNamesByUID (const 1 &iuids) const
 
VectorString getAllNames (bool excludeRankAndCoordinates=false, bool verbose=false) const
 
void setName (const String &old_name, const String &name)
 
void setName (const VectorString &list, const String &name)
 
void setNameByUID (Id iuid, const String &name)
 
void setNameByColIdx (Id icol, const String &name)
 
void setNameByLocator (const ELoc &locatorType, const String &name)
 
VectorString expandNameList (const VectorString &names) const
 
VectorString expandNameList (const String &names) const
 
VectorString identifyNames (const VectorString &names) const
 
Id getNUIDMax () const
 
Id getNColumn () const
 
Id getNSample (bool useSel=false) const
 
Id getNSampleActiveAndDefined (Id item) const
 
Id getNSampleActiveAndDefined (const String &name) const
 
Id getNSampleActive () const
 
Id getRankRelativeToAbsolute (Id irel) const
 
Id getRankAbsoluteToRelative (Id iabs) const
 
void clearLocators (const ELoc &locatorType)
 
void clearSelection ()
 
void setLocatorByUID (Id iuid, const ELoc &locatorType=ELoc::fromKey("UNKNOWN"), Id locatorIndex=0, bool cleanSameLocator=false)
 
void setLocatorByColIdx (Id icol, const ELoc &locatorType=ELoc::fromKey("UNKNOWN"), Id locatorIndex=0, bool cleanSameLocator=false)
 
void setLocator (const String &name, const ELoc &locatorType=ELoc::fromKey("UNKNOWN"), Id locatorIndex=0, bool cleanSameLocator=false)
 
void setLocators (const VectorString &names, const ELoc &locatorType=ELoc::fromKey("UNKNOWN"), Id locatorIndex=0, bool cleanSameLocator=false)
 
void setLocatorsByUID (Id number, Id iuid, const ELoc &locatorType=ELoc::fromKey("UNKNOWN"), Id locatorIndex=0, bool cleanSameLocator=false)
 
void setLocatorsByUID (const 1 &iuids, const ELoc &locatorType=ELoc::fromKey("UNKNOWN"), Id locatorIndex=0, bool cleanSameLocator=false)
 
void setLocatorsByColIdx (const 1 &icols, const ELoc &locatorType=ELoc::fromKey("UNKNOWN"), Id locatorIndex=0, bool cleanSameLocator=false)
 
void addColumnsByVVD (const 1 &tab, const String &radix, const ELoc &locatorType, Id locatorIndex=0, bool useSel=false)
 
Id addColumns (const 1 &tab, const String &radix="New", const ELoc &locatorType=ELoc::fromKey("UNKNOWN"), Id locatorIndex=0, bool useSel=false, double valinit=0., Id nvar=1)
 
Id addColumnsByConstant (Id nadd=1, double valinit=0., const String &radix="New", const ELoc &locatorType=ELoc::fromKey("UNKNOWN"), Id locatorIndex=0, Id nechInit=0)
 
Id addColumnsRandom (Id nadd, const String &radix="New", const ELoc &locatorType=ELoc::fromKey("Z"), Id locatorIndex=0, Id seed=1352, Id nechInit=0)
 
Id addSelection (const 1 &tab=1(), const String &name="NewSel", const String &combine="set")
 
Id addSelectionByVariable (const String &varname, double lower=TEST, double upper=TEST, const String &name="NewSel", const String &oldSelName="")
 Create a selection by testing a target variable against 'lower' and 'upper'.
 
Id addSelectionByRanks (const 1 &ranks, const String &name="NewSel", const String &combine="set")
 
Id addSelectionByLimit (const String &testvar, const Limits &limits=Limits(), const String &name="NewSel", const String &combine="set")
 
Id addSelectionFromDbByConvexHull (Db *db, double dilate=0., bool verbose=false, const NamingConvention &namconv=NamingConvention("Hull", true, true, true, ELoc::fromKey("SEL")))
 
Id addSelectionRandom (double prop, Id seed=138213, const String &name="NewSel", const String &combine="set")
 
Id addSamples (Id nadd, double valinit=TEST)
 
Id deleteSample (Id e_del)
 
Id deleteSamples (const 1 &e_dels)
 
void switchLocator (const ELoc &locatorType_in, const ELoc &locatorType_out)
 
Id getLastUID (Id number=0) const
 
String getLastName (Id number=0) const
 
Id getColIdx (const String &name) const
 
Id getColIdxByUID (Id iuid) const
 
Id getColIdxByLocator (const ELoc &locatorType, Id locatorIndex=0) const
 
 getColIdxs (const String &name) const
 
 getColIdxs (const VectorString &names) const
 
 getColIdxsByUID (const 1 &iuids) const
 
 getColIdxsByLocator (const ELoc &locatorType) const
 
void setColumn (const 1 &tab, const String &name, const ELoc &locatorType=ELoc::fromKey("UNKNOWN"), Id locatorIndex=0, bool useSel=false)
 
void setColumnByUIDOldStyle (const double *tab, Id iuid, bool useSel=false)
 
void setColumnByUID (const 1 &tab, Id iuid, bool useSel=false)
 
void setColumnByColIdx (const 1 &tab, Id icol, bool useSel=false)
 
void setColumnsByColIdx (const 1 &tabs, const 1 &icols, bool useSel=false)
 
void setColumnByColIdxOldStyle (const double *tab, Id icol, bool useSel=false)
 
void duplicateColumnByUID (Id iuid_in, Id iuid_out)
 
 getItem (const 1 &rows, const VectorString &colnames, bool useSel=false) const
 
 getItem (const 1 &rows, const String &colname, bool useSel=false) const
 
 getItem (const 1 &rows, const ELoc &locatorType, bool useSel=false) const
 
 getItem (const VectorString &colnames, bool useSel=false) const
 
 getItem (const String &colname, bool useSel=false) const
 
 getItem (const ELoc &locatorType, bool useSel=false) const
 
VectorString getItemNames (const VectorString &colnames) const
 
VectorString getItemNames (const String &colname) const
 
VectorString getItemNames (const ELoc &locatorType) const
 
Id setItem (const 1 &rows, const VectorString &colnames, const 1 &values, bool useSel=false)
 
Id setItem (const 1 &rows, const ELoc &locatorType, const 1 &values, bool useSel=false)
 
Id setItem (const VectorString &colnames, const 1 &values, bool useSel=false)
 
Id setItem (const ELoc &locatorType, const 1 &values, bool useSel=false)
 
Id setItem (const 1 &rows, const String &colname, const 1 &values, bool useSel=false)
 
Id setItem (const String &colname, const 1 &values, bool useSel=false)
 
bool getLocator (const String &name, ELoc *ret_locatorType, Id *ret_locatorIndex) const
 
bool getLocatorByColIdx (Id icol, ELoc *ret_locatorType, Id *ret_locatorIndex) const
 
bool getLocatorByUID (Id iuid, ELoc *ret_locatorType, Id *ret_locatorIndex) const
 
VectorString getLocators (bool anyLocator=true, const ELoc &locatorType=ELoc::fromKey("UNKNOWN")) const
 
bool isUIDDefined (Id iuid) const
 
Id getUID (const String &name) const
 
Id getUIDByColIdx (Id icol) const
 
Id getUIDByLocator (const ELoc &locatorType, Id locatorIndex=0) const
 
 getUIDs (const VectorString &names) const
 
 getUIDsByLocator (const ELoc &locatorType) const
 
 getUIDsByColIdx (const 1 &icols) const
 
 getAllUIDs () const
 
void getAllUIDs (1 &iuids) const
 
void copyByUID (Id iuidIn, Id iuidOut)
 
void copyByCol (Id icolIn, Id icolOut)
 
Id getNFacies (void) const
 
bool hasLocatorDefined (const String &name, const ELoc &locatorType, Id locatorIndex=0) const
 
 getSampleCoordinates (Id iech) const
 
void getSampleAsSPInPlace (SpacePoint &P, Id iabs) const
 In the SpacePoint 'P', define the sample rank and coordinates.
 
virtual void getSampleAsSTInPlace (Id iech, SpaceTarget &P) const
 
 getSampleLocators (const ELoc &locatorType, Id iech) const
 
 getIncrements (const 1 &iechs, const 1 &jechs) const
 
 getOneCoordinate (Id idim, bool useSel=false, bool flag_rotate=true) const
 
 getAllCoordinates (bool useSel=false) const
 
MatrixDense getAllCoordinatesMat (const MatrixDense &box=MatrixDense()) const
 
void setCoordinate (Id iech, Id idim, double value)
 
void setCoordinates (Id idim, const 1 &coor, bool useSel=false)
 
void setSampleCoordinates (Id iech, const 1 &coor)
 
double getDistance1D (Id iech, Id jech, Id idim=0, bool flagAbs=false) const
 
double getDistance (Id iech, Id jech) const
 
Id getDistanceVecInPlace (Id iech, Id jech, 1 &dd, const Db *db2=nullptr) const
 
double getValue (const String &name, Id iech) const
 
void setValue (const String &name, Id iech, double value)
 
double getArray (Id iech, Id iuid) const
 
void getArrayVec (const 1 &iechs, Id iuid, 1 &values) const
 
void setArray (Id iech, Id iuid, double value)
 
void setArrayVec (const 1 &iechs, Id iuid, const 1 &values)
 
void updArray (Id iech, Id iuid, const EOperator &oper, double value)
 
void updArrayVec (const 1 &iechs, Id iuid, const EOperator &oper, 1 &values)
 
 getArrayByUID (Id iuid, bool useSel=false) const
 
void setArrayByUID (const 1 &tab, Id iuid)
 
void getArrayBySample (std::vector< double > &vals, Id iech) const
 
void setArrayBySample (Id iech, const 1 &vec)
 
void getSamplesAsSP (std::vector< SpacePoint > &pvec, const ASpaceSharedPtr &space, bool useSel=false) const
 
void getSamplesFromNbghAsSP (std::vector< SpacePoint > &pvec, const 1 &nbgh) const
 
bool hasLocator (const ELoc &locatorType) const
 
double getFromLocator (const ELoc &locatorType, Id iech, Id locatorIndex=0) const
 
void setFromLocator (const ELoc &locatorType, Id iech, Id locatorIndex, double value)
 
double getValueByColIdx (Id iech, Id icol, bool flagCheck=true) const
 
const double * getColAdressByColIdx (Id icol) const
 
void setValueByColIdx (Id iech, Id icol, double value, bool flagCheck=true)
 
 getValuesByNames (const 1 &iechs, const VectorString &names, bool bySample=false) const
 
 getValuesByColIdx (const 1 &iechs, const 1 &icols, bool bySample=false) const
 
void setValuesByNames (const 1 &iechs, const VectorString &names, const 1 &values, bool bySample=false)
 
void setValuesByColIdx (const 1 &iechs, const 1 &icols, const 1 &values, bool bySample=false)
 
Id getNLoc (const ELoc &loctype) const
 
bool hasLocVariable (const ELoc &loctype) const
 
double getLocVariable (const ELoc &loctype, Id iech, Id item) const
 
void setLocVariable (const ELoc &loctype, Id iech, Id item, double value)
 
void updLocVariable (const ELoc &loctype, Id iech, Id item, const EOperator &oper, double value)
 
Id getNZValues () const
 
bool hasZVariable () const
 
double getZVariable (Id iech, Id item) const
 
void setZVariable (Id iech, Id item, double value)
 
void updZVariable (Id iech, Id item, const EOperator &oper, double value)
 
 getLocVariables (const ELoc &loctype, Id iech, Id nitemax=0) const
 
void setLocVariables (const ELoc &loctype, Id iech, const 1 &values)
 
bool isNVarComparedTo (Id nvar, Id compare=0) const
 
bool isIsotopic (Id iech, Id nvar_max=-1) const
 
bool isAllUndefined (Id iech) const
 
bool isAllUndefinedByType (const ELoc &loctype, Id iech) const
 
bool isAllIsotopic () const
 
void setInterval (Id iech, Id item, double rklow=TEST, double rkup=TEST)
 
Id getNInterval () const
 
void setBound (Id iech, Id item, double lower=TEST, double upper=TEST)
 
 getWithinBounds (Id item, bool useSel=false) const
 
 getGradient (Id item, bool useSel=false) const
 
 getTangent (Id item, bool useSel=false) const
 
 getCodeList (void) const
 
Id getSelection (Id iech) const
 
 getSelections (void) const
 
void getSampleRanksPerVariable (1 &ranks, const 1 &nbgh=1(), Id ivar=-1, bool useSel=true, bool useZ=true, bool useVerr=false, bool useExtD=true) const
 Create the vector of elligible sample ranks for the variable 'ivar'.
 
 getSampleRanks (const 1 &ivars=1(), const 1 &nbgh=1(), bool useSel=true, bool useZ=true, bool useVerr=false, bool useExtD=true) const
 
void getSampleRanksInPlace (1 &sampleRanks, const 1 &ivars=1(), const 1 &nbgh=1(), bool useSel=true, bool useZ=true, bool useVerr=false, bool useExtD=true) const
 
 getValuesByRanks (const 1 &sampleRanks, const 1 &means=1(), bool subtractMean=true) const
 
void getValuesByRanksInPlace (1 *values, const 1 &sampleRanks, const 1 &means=1(), bool subtractMean=true) const
 
Id getListOfSampleIndicesPerVariableInPlace (1 &ranks, Id ivar=0, bool useSel=true) const
 Returns the vector of indices for samples with variable 'ivar' defined For the target variable 'ivar' and for sample 'iech',.
 
Id getListOfSampleIndicesInPlace (Id nvar, 1 &cumul, 1 &ranks, bool useSel=true) const
 Updates (and resizes) the two arguments:
 
double getWeight (Id iech) const
 
 getWeights (bool useSel=false) const
 
double getSimvar (const ELoc &locatorType, Id iech, Id isimu, Id ivar, Id icase, Id nbsimu, Id nvar) const
 
void setSimvar (const ELoc &locatorType, Id iech, Id isimu, Id ivar, Id icase, Id nbsimu, Id nvar, double value)
 
void updSimvar (const ELoc &locatorType, Id iech, Id isimu, Id ivar, Id icase, Id nbsimu, Id nvar, const EOperator &oper, double value)
 
bool isActive (Id iech) const
 
bool isActiveDomain (Id iech) const
 
bool isActiveAndDefined (Id iech, Id item) const
 
VectorBool getActiveArray () const
 
 getSortArray () const
 
double getCosineToDirection (Id iech1, Id iech2, const 1 &codir) const
 
 getColumn (const String &name, bool useSel=false, bool flagCompress=true) const
 
 getColumnByUID (Id iuid, bool useSel=false, bool flagCompress=true) const
 
 getColumnByLocator (const ELoc &locatorType, Id locatorIndex=0, bool useSel=false, bool flagCompress=true) const
 
 getColumnByColIdx (Id icol, bool useSel=false, bool flagCompress=true) const
 
 getAllColumns (bool useSel=false, bool flagCompress=true) const
 
 getColumns (const VectorString &names=VectorString(), bool useSel=false, bool flagCompress=true, const 1 &origins=1()) const
 
 getColumnsAsVVD (const VectorString &names=VectorString(), bool useSel=false, bool flagCompress=true) const
 
MatrixDense getColumnsAsMatrix (const VectorString &names, bool useSel=false, bool flagCompress=true) const
 
 getColumnsByColIdx (const 1 &icols=1(), bool useSel=false, bool flagCompress=true, const 1 &origins=1()) const
 
 getColumnsByColIdxInterval (Id icol_beg, Id icol_end, bool useSel=false, bool flagCompress=true) const
 
 getColumnsActiveAndDefined (const ELoc &locatorType, const 1 &origins=1()) const
 
 getColumnsByLocator (const ELoc &locatorType, bool useSel=false, bool flagCompress=true, const 1 &origins=1()) const
 
 getColumnsByUID (const 1 &iuids, bool useSel=false, bool flagCompress=true, const 1 &origins=1()) const
 
 getColumnsByUIDInterval (Id iuid_beg, Id iuid_end, bool useSel=false, bool flagCompress=true) const
 
void setAllColumns (const 1 &tabs)
 
void deleteColumn (const String &name)
 
void deleteColumnByUID (Id iuid_del)
 
void deleteColumnByColIdx (Id icol_del)
 
void deleteColumns (const VectorString &names)
 
void deleteColumnsByLocator (const ELoc &locatorType)
 
void deleteColumnsByUID (const 1 &iuids)
 
void deleteColumnsByColIdx (const 1 &icols)
 
void deleteColumnsByUIDRange (Id i_del, Id n_del)
 
 getExtrema (Id idim, bool useSel=false) const
 
 getExtremas (bool useSel=false) const
 
 getExtends (bool useSel=false) const
 
 getCoorMinimum (bool useSel=false) const
 
 getCoorMaximum (bool useSel=false) const
 
double getExtension (Id idim, bool useSel=false) const
 
double getExtensionDiagonal (bool useSel=false) const
 
double getCenter (Id idim, bool useSel=false) const
 
 getCenters (bool useSel=false) const
 
void getExtensionInPlace (1 &mini, 1 &maxi, bool flagPreserve=false, bool useSel=false) const
 
double getMinimum (const String &name, bool useSel=false) const
 
double getMaximum (const String &name, bool useSel=false) const
 
 getRange (const String &name, bool useSel=false) const
 
double getMean (const String &name, bool useSel=false) const
 
double getVariance (const String &name, bool useSel=false) const
 
double getStdv (const String &name, bool useSel=false) const
 
double getCorrelation (const String &name1, const String &name2, bool useSel=false) const
 
bool hasSameDimension (const Db *dbaux) const
 
bool hasLargerDimension (const Db *dbaux) const
 
bool isColIdxValid (Id icol) const
 
bool isUIDValid (Id iuid) const
 
bool isSampleIndexValid (Id iech) const
 
bool isSampleIndicesValid (const 1 &iechs, bool useSel=false) const
 
bool isLocatorIndexValid (const ELoc &locatorType, Id locatorIndex) const
 
bool isDimensionIndexValid (Id idim) const
 
void combineSelection (1 &sel, const String &combine="set") const
 
void generateRank (const String &radix="rank")
 
 shrinkToValidRows (const 1 &rows) const
 
 shrinkToValidCols (const 1 &cols) const
 
void statisticsBySample (const VectorString &names, const std::vector< EStatOption > &opers=EStatOption::fromKeys({"MEAN"}), bool flagIso=true, double proba=TEST, double vmin=TEST, double vmax=TEST, const NamingConvention &namconv=NamingConvention("Stats"))
 
 statisticsMulti (const VectorString &names, bool flagIso=true, bool verbose=false, const String &title="")
 
bool areSame (const String &name1, const String &name2, double eps=EPSILON3, bool useSel=true, bool verbose=false) const
 
 filter (const String &name, const Interval &interval, Id belowRow=ITEST, Id aboveRow=ITEST) const
 
Table printOneSample (Id iech, const VectorString &names=VectorString(), bool excludeCoordinates=true, bool skipTitle=false) const
 
void dumpGeometry (Id iech, Id jech) const
 
- Public Member Functions inherited from gstlrn::AStringable
 AStringable ()
 
 AStringable (const AStringable &r)
 
AStringableoperator= (const AStringable &r)
 
virtual ~AStringable ()
 
virtual void display (const AStringFormat *strfmt=nullptr) const final
 
virtual void display (Id level) const final
 
- Public Member Functions inherited from gstlrn::ASerializable
 ASerializable ()
 
 ASerializable (const ASerializable &r)
 
ASerializableoperator= (const ASerializable &r)
 
 ASerializable (ASerializable &&r) noexcept
 
ASerializableoperator= (ASerializable &&r) noexcept
 
virtual ~ASerializable ()
 
bool dumpToNF (const String &NFFilename, const EFormatNF &format=EFormatNF::fromKey("DEFAULT"), bool verbose=false) const
 Dump the contents of an object into an Output File using a given Output NF Format.
 
void setDefaultFormatNF (const EFormatNF &format)
 
- Public Member Functions inherited from gstlrn::ICloneable
 ICloneable ()
 
virtual ~ICloneable ()
 
virtual ICloneableclone () const =0
 
std::shared_ptr< ICloneablecloneShared () const
 
std::unique_ptr< ICloneablecloneUnique () const
 

Static Public Member Functions

static Dbcreate ()
 
static DbcreateFromNF (const String &NFFilename, bool verbose=true)
 
static DbcreateFromSamples (Id nech, const ELoadBy &order=ELoadBy::fromKey("SAMPLE"), const 1 &tab=1(), const VectorString &names=VectorString(), const VectorString &locatorNames=VectorString(), bool flagAddSampleRank=true)
 
static DbcreateFromCSV (const String &filename, const CSVformat &csv=CSVformat(), bool verbose=false, Id ncol_max=-1, Id nrow_max=-1, bool flagAddSampleRank=true)
 
static DbcreateFromBox (Id nech, const 1 &coormin, const 1 &coormax, Id seed=43241, bool flag_exact=true, bool flag_repulsion=false, double range=0., double beta=0., double extend=0., bool flagAddSampleRank=true)
 
static DbcreateFromOnePoint (const 1 &tab=1(), bool flagAddSampleRank=true)
 
static DbcreateSamplingDb (const Db *dbin, double proportion=0., Id number=0, const VectorString &names=VectorString(), Id seed=23241, bool verbose=false, bool flagAddSampleRank=true)
 
static DbcreateFromDbGrid (Id nech, DbGrid *dbgrid, Id seed=432423, bool flag_exact=true, bool flag_repulsion=false, double range=0., double beta=0., bool flagAddSampleRank=true)
 
static DbcreateReduce (const Db *dbin, const VectorString &names=VectorString(), const 1 &ranks=1(), bool verbose=false)
 
static DbcreateFillRandom (Id ndat, Id ndim=2, Id nvar=1, Id nfex=0, Id ncode=0, double varmax=0., double selRatio=0., const 1 &heteroRatio=1(), const 1 &coormin=1(), const 1 &coormax=1(), Id seed=124234, bool flagAddSampleRank=true)
 
static DbcreateEmpty (Id ndat, Id ndim=2, Id nvar=1, Id nfex=0, Id ncode=0, bool flagVerr=false, bool flagSel=false, bool flagAddSampleRank=true)
 
static DbcreateFromGridRandomized (DbGrid *dbgrid, double randperc=0., bool flagAddSampleRank=true)
 
static Id getNEloc ()
 
static getMultipleSelectedRanks (const 1 &index, const 1 &ivars=1(), const 1 &nbgh=1())
 Return the vector of the ranks within 'index' of data beloging:
 
static getMultipleSelectedVariables (const 1 &index, const 1 &ivars=1(), const 1 &nbgh=1())
 
static Id getSimRank (Id isimu, Id ivar, Id icase, Id nbsimu, Id nvar)
 
static const DbcoverSeveralDbs (const Db *db1, const Db *db2, bool *isBuilt)
 
- Static Public Member Functions inherited from gstlrn::ASerializable
static String buildFileName (Id status, const String &filename, bool ensureDirExist=false)
 
static String getFileIdentity (const String &filename, bool verbose=false)
 
static void setPrefixName (const String &prefixName)
 
static void unsetPrefixName ()
 
static const StringgetPrefixName ()
 

Public Attributes

 DECLARE_TOTL
 Has a specific implementation in the Target language.
 

Constructor & Destructor Documentation

◆ Db() [1/2]

gstlrn::Db::Db ( )

◆ Db() [2/2]

gstlrn::Db::Db ( const Db r)

◆ ~Db()

gstlrn::Db::~Db ( )
virtual

Member Function Documentation

◆ addColumns()

Id gstlrn::Db::addColumns ( const 1 &  tab,
const String radix = "New",
const ELoc &  locatorType = ELoc::fromKey("UNKNOWN"),
Id  locatorIndex = 0,
bool  useSel = false,
double  valinit = 0.,
Id  nvar = 1 
)

Add one or several columns to an already existing Db. This is performed by providing an array of values 'tab'. Its dimension must be equal to the number of samples (or active samples if 'useSel' is true, times the number of variables 'nvar'.

Parameters
tabArray to be loaded
radixGeneric name for the newly created variables
locatorTypeGeneric locator assigned to new variables
locatorIndexLocator index (starting from 0)
useSeltrue if the Selection must be taken into account
valinitinitial value (for unselected samples)
nvarNumber of variables loaded
Returns
Rank of the first UID
Remarks
When 'useSel' is used, you must have a Selection already defined. Then the number
of samples provided in 'tab' must match the number of active samples
When a vector 'tab' is provided, the number of variables 'nvar'
is calculated as its size divided by the number of samples in the grid.

◆ addColumnsByConstant()

Id gstlrn::Db::addColumnsByConstant ( Id  nadd = 1,
double  valinit = 0.,
const String radix = "New",
const ELoc &  locatorType = ELoc::fromKey("UNKNOWN"),
Id  locatorIndex = 0,
Id  nechInit = 0 
)

Create a set of new variables in an already existing Db and initialize their contents to a constant value

Parameters
naddNumber of variables to be added
valinitValue to be used for variable initialization
radixGeneric radix given to the newly created variables
locatorTypeGeneric locator assigned to new variables
locatorIndexLocator index (starting from 0)
nechInitNumber of samples (used only if the Db is initially empty)
Returns
Rank of the first UID

◆ addColumnsByVVD()

void gstlrn::Db::addColumnsByVVD ( const 1 &  tab,
const String radix,
const ELoc &  locatorType,
Id  locatorIndex = 0,
bool  useSel = false 
)

◆ addColumnsRandom()

Id gstlrn::Db::addColumnsRandom ( Id  nadd,
const String radix = "New",
const ELoc &  locatorType = ELoc::fromKey("Z"),
Id  locatorIndex = 0,
Id  seed = 1352,
Id  nechInit = 0 
)

Create a set of new variables in an already existing Db and initialize their contents as a random value (from Normal distribution)

Parameters
naddNumber of variables to be added
radixGeneric radix given to the newly created variables
locatorTypeGeneric locator assigned to new variables
locatorIndexLocator index (starting from 0)
seedSeed value
nechInitNumber of samples (used only if the Db is initially empty)
Returns
Rank of the first UID

◆ addSamples()

Id gstlrn::Db::addSamples ( Id  nadd,
double  valinit = TEST 
)

Add samples to the Data Base

Parameters
naddNumber of samples to be added
valinitDefault value given to the added samples
Returns
Index of the first newly added sample (or -1 if adding samples is not authorized)

◆ addSelection()

Id gstlrn::Db::addSelection ( const 1 &  tab = 1(),
const String name = "NewSel",
const String combine = "set" 
)

Add the contents of the 'tab' as a Selection

Parameters
tabInput array
nameName given to the newly created Selection variable
combineHow to combine with an already existing selection (see combineSelection() for details)
Returns
Rank of the newly created Column within the Data Base
Remarks
The Selection is set to True if tab is not zero and to False otherwise.
If the dimension of 'tab' does not match the number of samples in the Db
the action is cancelled (a message is issued)

◆ addSelectionByLimit()

Id gstlrn::Db::addSelectionByLimit ( const String testvar,
const Limits limits = Limits(),
const String name = "NewSel",
const String combine = "set" 
)

Create a selection around the only defined values of the target variable

Parameters
testvarName of the target variable
limitsLimits defining the Definition Domain to be tested (optional)
nameName of the newly created selection
combineHow to combine with an already existing selection (see combineSelection() for details)
Returns
The rank of the newly created selection variable within the Db

◆ addSelectionByRanks()

Id gstlrn::Db::addSelectionByRanks ( const 1 &  ranks,
const String name = "NewSel",
const String combine = "set" 
)

Add a Selection by considering the input 'ranks' vector which give the ranks of the active samples (starting from 0)

Parameters
ranksVector of ranks of active samples
nameName given to the newly created Selection variable
combineHow to combine with an already existing selection (see combineSelection() for details)
Returns

◆ addSelectionByVariable()

Id gstlrn::Db::addSelectionByVariable ( const String varname,
double  lower = TEST,
double  upper = TEST,
const String name = "NewSel",
const String oldSelName = "" 
)

Create a selection by testing a target variable against 'lower' and 'upper'.

Parameters
varnameName of the target variable
lowerLower bound (included) or TEST for no lower bound
upperUpper bound (included) or TEST for no upper bound
nameName given to the newly created selection
oldSelNameIf defined, the current selection is combined with the existing one
Returns
Id

◆ addSelectionFromDbByConvexHull()

Id gstlrn::Db::addSelectionFromDbByConvexHull ( Db db,
double  dilate = 0.,
bool  verbose = false,
const NamingConvention namconv = NamingConvention("Hull", true, true, true, ELoc::fromKey("SEL")) 
)

Create a Selection based on the Convex Hull of the active samples of 'Db'

Parameters
dbData Base providing the (active) samples
dilateThe convex hull can be dilated: this gives the radius
verboseVerbose option
namconvNaming Convention
Returns

◆ addSelectionRandom()

Id gstlrn::Db::addSelectionRandom ( double  prop,
Id  seed = 138213,
const String name = "NewSel",
const String combine = "set" 
)

Create a Selection based on a proportion of active samples

Parameters
propProportion of active samples (between 0 and 1)
seedSeed for the random number generator
nameName of the newly created selection
combineHow to combine with an already existing selection (see combineSelection() for details)
Returns

◆ areSame()

bool gstlrn::Db::areSame ( const String name1,
const String name2,
double  eps = EPSILON3,
bool  useSel = true,
bool  verbose = false 
) const

◆ clearLocators()

void gstlrn::Db::clearLocators ( const ELoc &  locatorType)

◆ clearSelection()

void gstlrn::Db::clearSelection ( )
inline

◆ combineSelection()

void gstlrn::Db::combineSelection ( 1 &  sel,
const String combine = "set" 
) const

Combine 'sel' input argument with an already existing selection (if any)

Parameters
selInput selection (only 0 and 1)
combineType of combination: "set", "not", "or", "and", "xor"
Remarks
Argument 'sel' may be modified by this procedure

◆ copyByCol()

void gstlrn::Db::copyByCol ( Id  icolIn,
Id  icolOut 
)

◆ copyByUID()

void gstlrn::Db::copyByUID ( Id  iuidIn,
Id  iuidOut 
)

◆ coverSeveralDbs()

const Db * gstlrn::Db::coverSeveralDbs ( const Db db1,
const Db db2,
bool *  isBuilt 
)
static

◆ deleteSample()

Id gstlrn::Db::deleteSample ( Id  e_del)

Deleting a sample

Parameters
e_delIndex of the sample to be deleted
Returns
0 if successfull or -1 if sample deletion is not authorized

◆ deleteSamples()

Id gstlrn::Db::deleteSamples ( const 1 &  e_dels)

◆ dumpGeometry()

void gstlrn::Db::dumpGeometry ( Id  iech,
Id  jech 
) const

◆ duplicateColumnByUID()

void gstlrn::Db::duplicateColumnByUID ( Id  iuid_in,
Id  iuid_out 
)

◆ filter()

gstlrn::Db::filter ( const String name,
const Interval interval,
Id  belowRow = ITEST,
Id  aboveRow = ITEST 
) const

Find the occurrence of a given range of values for a given variable

Parameters
nameName of the Target variable
intervalInterval definition
belowRowIf specified, search must be performed below this row
aboveRowIf specified, search must be performed above this row
Returns

◆ generateRank()

void gstlrn::Db::generateRank ( const String radix = "rank")

◆ getActiveArray()

VectorBool gstlrn::Db::getActiveArray ( ) const

◆ getAllCoordinates()

gstlrn::Db::getAllCoordinates ( bool  useSel = false) const

Constitute a Vector of Vector of coordinates for all (active) samples

  • the first dimension is the space dimension
  • the second dimension is the number of (active) samples
    Parameters
    useSel
    Returns

◆ getAllCoordinatesMat()

MatrixDense gstlrn::Db::getAllCoordinatesMat ( const MatrixDense box = MatrixDense()) const

Constitute a Matrix of coordinates for all (active) samples

  • one row per sample
  • one column by Space Dimension
    Returns

◆ getAllUIDs() [1/2]

gstlrn::Db::getAllUIDs ( ) const

◆ getAllUIDs() [2/2]

void gstlrn::Db::getAllUIDs ( 1 &  iuids) const

◆ getArray()

double gstlrn::Db::getArray ( Id  iech,
Id  iuid 
) const

Return the value defined by Sample and UID

Parameters
iechSample Index
iuidUID Index
Returns

◆ getArrayBySample()

void gstlrn::Db::getArrayBySample ( std::vector< double > &  vals,
Id  iech 
) const

◆ getArrayByUID()

gstlrn::Db::getArrayByUID ( Id  iuid,
bool  useSel = false 
) const

◆ getArrays()

const std::vector< double > & gstlrn::Db::getArrays ( ) const
inline

◆ getArrayVec()

void gstlrn::Db::getArrayVec ( const 1 &  iechs,
Id  iuid,
1 &  values 
) const

Get the values of a series of samples

Parameters
iechsList of sample indices
iuidIndex of the UID
valuesList of values to be written
Remarks
: for efficiency purpose, no check is performed on the sample ranks

◆ getCodeList()

gstlrn::Db::getCodeList ( void  ) const

Returns the list of Unique codes

Returns
Pointer to the array containing a single occurence of each code

◆ getColAdressByColIdx()

const double * gstlrn::Db::getColAdressByColIdx ( Id  icol) const

◆ getColIdx()

Id gstlrn::Db::getColIdx ( const String name) const

Returns the rank of the Single Column corresponding to 'name'

Parameters
nameNamed for the searched column
Returns
The rank of the Single column or -1

◆ getColIdxByLocator()

Id gstlrn::Db::getColIdxByLocator ( const ELoc &  locatorType,
Id  locatorIndex = 0 
) const

Find Column for a given Locator characteristics

Parameters
locatorTypeLocator type
locatorIndexLocator index (starting from 0)
Returns

◆ getColIdxByUID()

Id gstlrn::Db::getColIdxByUID ( Id  iuid) const

◆ getColIdxs() [1/2]

gstlrn::Db::getColIdxs ( const String name) const

◆ getColIdxs() [2/2]

gstlrn::Db::getColIdxs ( const VectorString names) const

◆ getColIdxsByLocator()

gstlrn::Db::getColIdxsByLocator ( const ELoc &  locatorType) const

◆ getColIdxsByUID()

gstlrn::Db::getColIdxsByUID ( const 1 &  iuids) const

◆ getCoordinate()

double gstlrn::Db::getCoordinate ( Id  iech,
Id  idim,
bool  flag_rotate = true 
) const
virtual

Return the coordinate of a sample along one Space Dimension

Parameters
iechRank of the sample
idimRank of the Space Dimension
flag_rotateUse the rotation (only for Grid)
Returns

Reimplemented in gstlrn::DbGrid.

◆ getCoordinatesInPlace()

void gstlrn::Db::getCoordinatesInPlace ( 1 &  coor,
Id  iech,
bool  flag_rotate = true 
) const
virtual

Update the vector of coordinates (optimized manner) No check is done with respect to the dimension of the returned vector.

Parameters
coorReturned vector of coordinates (should be dimensionned beforehand)
iechRank of the target
flag_rotateTrue if Grid rotation must be taken into account

Reimplemented in gstlrn::DbGrid.

◆ getCosineToDirection()

double gstlrn::Db::getCosineToDirection ( Id  iech1,
Id  iech2,
const 1 &  codir 
) const

Calculates the cosine of the angle between a reference direction and the increment between two points in the same Db

Returns
Cosine of the angle
Parameters
[in]iech1rank of the first sample
[in]iech2rank of the second sample
[in]codirDirection coefficient

◆ getDistance()

double gstlrn::Db::getDistance ( Id  iech,
Id  jech 
) const

◆ getDistance1D()

double gstlrn::Db::getDistance1D ( Id  iech,
Id  jech,
Id  idim = 0,
bool  flagAbs = false 
) const

◆ getDistanceVecInPlace()

Id gstlrn::Db::getDistanceVecInPlace ( Id  iech,
Id  jech,
1 &  dd,
const Db db2 = nullptr 
) const

Calculate the distance vector in place

Parameters
iechRank of the first sample
jechRank of the second sample (from db2 if db2 provided)
ddVector for distances (It must be dimensioned to getNDim())
db2Second Db if different from current one (or nullptr)
Returns

◆ getFromLocator()

double gstlrn::Db::getFromLocator ( const ELoc &  locatorType,
Id  iech,
Id  locatorIndex = 0 
) const

◆ getGradient()

gstlrn::Db::getGradient ( Id  item,
bool  useSel = false 
) const

◆ getIncrements()

gstlrn::Db::getIncrements ( const 1 &  iechs,
const 1 &  jechs 
) const

◆ getItem() [1/6]

gstlrn::Db::getItem ( const 1 &  rows,
const ELoc &  locatorType,
bool  useSel = false 
) const

◆ getItem() [2/6]

gstlrn::Db::getItem ( const 1 &  rows,
const String colname,
bool  useSel = false 
) const

◆ getItem() [3/6]

gstlrn::Db::getItem ( const 1 &  rows,
const VectorString colnames,
bool  useSel = false 
) const

◆ getItem() [4/6]

gstlrn::Db::getItem ( const ELoc &  locatorType,
bool  useSel = false 
) const

◆ getItem() [5/6]

gstlrn::Db::getItem ( const String colname,
bool  useSel = false 
) const

◆ getItem() [6/6]

gstlrn::Db::getItem ( const VectorString colnames,
bool  useSel = false 
) const

◆ getItemNames() [1/3]

VectorString gstlrn::Db::getItemNames ( const ELoc &  locatorType) const

◆ getItemNames() [2/3]

VectorString gstlrn::Db::getItemNames ( const String colname) const

◆ getItemNames() [3/3]

VectorString gstlrn::Db::getItemNames ( const VectorString colnames) const

◆ getLastName()

String gstlrn::Db::getLastName ( Id  number = 0) const

◆ getLastUID()

Id gstlrn::Db::getLastUID ( Id  number = 0) const

Returns the rank of (one of) the lastly added UID in the Db

Parameters
number0 designates the last, 1 the one before last...
Returns

◆ getListOfSampleIndicesInPlace()

Id gstlrn::Db::getListOfSampleIndicesInPlace ( Id  nvar,
1 &  cumul,
1 &  ranks,
bool  useSel = true 
) const

Updates (and resizes) the two arguments:

  • cumul cumulated number of samples where each variable is defined
  • ranks Each vector gives the ranks of defined samples (or ITEST) if not defined These two arguments have 'nvar' as first dimension
Parameters
nvarNumber of variables
cumulVector of cumulated number of defined samples per variable
ranksVector of vectors of ranks of defined samples
useSelDiscard the masked samples (if True)
Returns
The total number of samples where ALL variables are defined
Remarks
Argument 'nvar' is provided as it may serve for a file which does not contain any variable (Loc::Z) defined.

◆ getListOfSampleIndicesPerVariableInPlace()

Id gstlrn::Db::getListOfSampleIndicesPerVariableInPlace ( 1 &  ranks,
Id  ivar = 0,
bool  useSel = true 
) const

Returns the vector of indices for samples with variable 'ivar' defined For the target variable 'ivar' and for sample 'iech',.

  • ranks[iech] = IFFFF if variable 'ivar' is not defined for sample 'iech'
  • ranks[iech] = 'ipos' if the variable 'ivar' is defined for sample 'iech', where 'ipos' is rank within the list of samples where 'ivar' is defined
Parameters
ranksVector of the (defined) sample indices
ivarIndex of the variable of interest
useSelDiscard the masked samples (if True)
Returns
Count of samples defined
Remarks
When the file has NO Z-locator variable defined, we consider that all active samples are available

◆ getLocator()

bool gstlrn::Db::getLocator ( const String name,
ELoc *  ret_locatorType,
Id ret_locatorIndex 
) const

Return the locator information corresponding to the input variable

Parameters
nameInput variable name (unique)
ret_locatorTypeLocator Type
ret_locatorIndexLocator Index (starting from 0)
Returns

◆ getLocatorByColIdx()

bool gstlrn::Db::getLocatorByColIdx ( Id  icol,
ELoc *  ret_locatorType,
Id ret_locatorIndex 
) const

Find the locator characteristics of a given Column

Parameters
icolIndex of the target column
ret_locatorTypeLocator type
ret_locatorIndexLocator index (starting from 0)
Returns
true if the target variable has a locator assigned and false otherwise

◆ getLocatorByUID()

bool gstlrn::Db::getLocatorByUID ( Id  iuid,
ELoc *  ret_locatorType,
Id ret_locatorIndex 
) const

◆ getLocators()

VectorString gstlrn::Db::getLocators ( bool  anyLocator = true,
const ELoc &  locatorType = ELoc::fromKey("UNKNOWN") 
) const

◆ getLocVariables()

gstlrn::Db::getLocVariables ( const ELoc &  loctype,
Id  iech,
Id  nitemax = 0 
) const

◆ getMultipleSelectedRanks()

gstlrn::Db::getMultipleSelectedRanks ( const 1 &  index,
const 1 &  ivars = 1(),
const 1 &  nbgh = 1() 
)
static

Return the vector of the ranks within 'index' of data beloging:

  • to the variable indices 'ivars' (default: all samples)
  • to the sample indices 'nbgh' (default: all samples)
Parameters
indexInput data information ranks
ivarsVector of selection variables
nbghVector of selection samples
Returns
VectorInt

◆ getMultipleSelectedVariables()

gstlrn::Db::getMultipleSelectedVariables ( const 1 &  index,
const 1 &  ivars = 1(),
const 1 &  nbgh = 1() 
)
static

◆ getNColumn()

Id gstlrn::Db::getNColumn ( ) const
inline

◆ getNDim()

Id gstlrn::Db::getNDim ( ) const
virtual

Reimplemented in gstlrn::DbGrid.

◆ getNEloc()

Id gstlrn::Db::getNEloc ( )
static

◆ getNFacies()

Id gstlrn::Db::getNFacies ( void  ) const

Returns the Number of different facies (labelling starts at 1) The facies variable must be locatorized as ELoc::Z and be unique

◆ getNInterval()

Id gstlrn::Db::getNInterval ( ) const

◆ getNSample()

Id gstlrn::Db::getNSample ( bool  useSel = false) const

Returns the Number of samples

Parameters
useSelWhen FALSE returns the total sample number. When TRUE returns the number of active samples
Returns

◆ getNSampleActive()

GSTLEARN_DEPRECATED Id gstlrn::Db::getNSampleActive ( ) const

Returns the number of active samples if a Selection is already defined.

If no Selection is currently defined, it returns the total number of samples (see getNSample())

Returns
Number of active samples
Remarks
This method is deprecated and should be replaced by a call to getNSample()

◆ getNSampleActiveAndDefined() [1/2]

Id gstlrn::Db::getNSampleActiveAndDefined ( const String name) const

Returns the number of active samples for which the variable 'name' is defined

Parameters
nameName of the Target variable
Returns
Number of samples

◆ getNSampleActiveAndDefined() [2/2]

Id gstlrn::Db::getNSampleActiveAndDefined ( Id  item) const

Returns the number of active samples for which the target variable (ELoc::Z) is defined

Parameters
itemRank of the ELoc::Z variable
Returns
Number of samples

◆ getNUIDMax()

Id gstlrn::Db::getNUIDMax ( ) const
inline

◆ getNZValues()

Id gstlrn::Db::getNZValues ( ) const

◆ getOneCoordinate()

gstlrn::Db::getOneCoordinate ( Id  idim,
bool  useSel = false,
bool  flag_rotate = true 
) const

Returns the vector of coordinates along a given Space Dimension

Parameters
idimRank of the Space dimension
useSelUse the Data Selection
flag_rotateFlag for rotation (only for Grid)
Returns

◆ getRankAbsoluteToRelative()

Id gstlrn::Db::getRankAbsoluteToRelative ( Id  iabs) const

◆ getRankRelativeToAbsolute()

Id gstlrn::Db::getRankRelativeToAbsolute ( Id  irel) const

Return the absolute rank of a sample from its relative rank

Parameters
irelRelative rank
Returns

◆ getSampleAsSPInPlace()

void gstlrn::Db::getSampleAsSPInPlace ( SpacePoint P,
Id  iabs 
) const

In the SpacePoint 'P', define the sample rank and coordinates.

Parameters
PSpacePoint reference (output)
iabsRank of the sample

◆ getSampleAsSTInPlace()

void gstlrn::Db::getSampleAsSTInPlace ( Id  iech,
SpaceTarget P 
) const
virtual

Load a Space Target with all possible contents gathered from Db

Parameters
iechRank of the target sample
PSpace Target (used to store information)

Reimplemented in gstlrn::DbGrid.

◆ getSampleCoordinates()

gstlrn::Db::getSampleCoordinates ( Id  iech) const

◆ getSampleLocators()

gstlrn::Db::getSampleLocators ( const ELoc &  locatorType,
Id  iech 
) const

◆ getSampleRanks()

gstlrn::Db::getSampleRanks ( const 1 &  ivars = 1(),
const 1 &  nbgh = 1(),
bool  useSel = true,
bool  useZ = true,
bool  useVerr = false,
bool  useExtD = true 
) const

Returns the list of indices 'index' for valid samples for the set of variables 'ivars'. Note: each address is ABSOLUTE to the target set of available samples.

Parameters
ivarsVector giving the indices of the variables of interest
nbghVector giving the ranks of the elligible samples (optional)
useSelDiscard the masked samples (if True)
useZDiscard samples when Z is not defined
useVerrDiscard the samples where Verr (optional) is not defined
useExtDTrue if the definition of the External Drift must be checked
Note
: if the current 'db' has some Z-variable defined, only samples
: where a variable is defined is considered (search for heterotopy).
: if 'nbgh' is not provided, the absolute and relative indices
: returned by this function are similar.
: if 'useExtD' is ON, each sample for each variable is tested against
: all the values of External Drift functions.

◆ getSampleRanksInPlace()

void gstlrn::Db::getSampleRanksInPlace ( 1 &  sampleRanks,
const 1 &  ivars = 1(),
const 1 &  nbgh = 1(),
bool  useSel = true,
bool  useZ = true,
bool  useVerr = false,
bool  useExtD = true 
) const

Compute the list of indices 'index' for valid samples for the set of variables 'ivars'. Note: each address is ABSOLUTE to the target set of available samples.

Parameters
sampleRanksReturn the list of indices 'index' for valid samples
ivarsVector giving the indices of the variables of interest
nbghVector giving the ranks of the elligible samples (optional)
useSelDiscard the masked samples (if True)
useZDiscard samples when Z is not defined
useVerrDiscard the samples where Verr (optional) is not defined
useExtDTrue if the definition of the External Drift must be checked
Note
: if the current 'db' has some Z-variable defined, only samples
: where a variable is defined is considered (search for heterotopy).
: if 'nbgh' is not provided, the absolute and relative indices
: returned by this function are similar.
: if 'useExtD' is ON, each sample for each variable is tested against
: all the values of External Drift functions.

◆ getSampleRanksPerVariable()

void gstlrn::Db::getSampleRanksPerVariable ( 1 &  ranks,
const 1 &  nbgh = 1(),
Id  ivar = -1,
bool  useSel = true,
bool  useZ = true,
bool  useVerr = false,
bool  useExtD = true 
) const

Create the vector of elligible sample ranks for the variable 'ivar'.

Parameters
ranksVector of elligible sample ranks (Input/Output)
nbghSet of potentiel sample ranks
ivarTarget variable rank
useSelTrue if the selection must be taken into account
useZTrue if the definition of the target variable must be checked
useVerrTrue if the definition of the Variance of Measurement Error must be checked
useExtDTrue if the definition of the External Drift must be checked

◆ getSamplesAsSP()

void gstlrn::Db::getSamplesAsSP ( std::vector< SpacePoint > &  pvec,
const ASpaceSharedPtr space,
bool  useSel = false 
) const

◆ getSamplesFromNbghAsSP()

void gstlrn::Db::getSamplesFromNbghAsSP ( std::vector< SpacePoint > &  pvec,
const 1 &  nbgh 
) const

◆ getSelection()

Id gstlrn::Db::getSelection ( Id  iech) const

Return the Selection value at Sample 'iech'

Parameters
iechSample number
Returns
Remarks
If the selection value if TEST, the sample is considered as masked off.

◆ getSelections()

gstlrn::Db::getSelections ( void  ) const

◆ getSortArray()

gstlrn::Db::getSortArray ( ) const

Return the vector of ordered samples by increasing coordinate along X

Returns
Array containing the increasing order
Remarks
The returned array must be desallocated

◆ getTangent()

gstlrn::Db::getTangent ( Id  item,
bool  useSel = false 
) const

◆ getUID()

Id gstlrn::Db::getUID ( const String name) const

Returns the Single UID which corresponds to the searched name

Parameters
nameName to be searched for
Returns
Rank of the UID or -1

◆ getUIDByColIdx()

Id gstlrn::Db::getUIDByColIdx ( Id  icol) const

◆ getUIDByLocator()

Id gstlrn::Db::getUIDByLocator ( const ELoc &  locatorType,
Id  locatorIndex = 0 
) const

◆ getUIDs()

gstlrn::Db::getUIDs ( const VectorString names) const

◆ getUIDsByColIdx()

gstlrn::Db::getUIDsByColIdx ( const 1 &  icols) const

◆ getUIDsByLocator()

gstlrn::Db::getUIDsByLocator ( const ELoc &  locatorType) const

◆ getUnit()

double gstlrn::Db::getUnit ( Id  idim = 0) const
virtual

Return a Unit calculated for a Db (in a given Space dimension)

Parameters
idimRank of the Space dimension
Returns
Remarks
This unit is defined as 1/1000 of the extension in the given space dimension

Reimplemented in gstlrn::DbGrid.

◆ getValue()

double gstlrn::Db::getValue ( const String name,
Id  iech 
) const

Returns the value of the 'iech' sample of the variable 'name'

This function does not use 'ids' mechanism in order to allow referring to a non-existing variable

◆ getValueByColIdx()

double gstlrn::Db::getValueByColIdx ( Id  iech,
Id  icol,
bool  flagCheck = true 
) const

◆ getValuesByColIdx()

gstlrn::Db::getValuesByColIdx ( const 1 &  iechs,
const 1 &  icols,
bool  bySample = false 
) const

◆ getValuesByNames()

gstlrn::Db::getValuesByNames ( const 1 &  iechs,
const VectorString names,
bool  bySample = false 
) const

◆ getValuesByRanks()

gstlrn::Db::getValuesByRanks ( const 1 &  sampleRanks,
const 1 &  means = 1(),
bool  subtractMean = true 
) const

Returns the values of the Z variables for the samples

Parameters
sampleRanksVector of ranks of the samples
meansVector of means (optional)
subtractMeanSubtract the mean from the values
Returns
VectorDouble

◆ getValuesByRanksInPlace()

void gstlrn::Db::getValuesByRanksInPlace ( 1 *  values,
const 1 &  sampleRanks,
const 1 &  means = 1(),
bool  subtractMean = true 
) const

◆ getWeight()

double gstlrn::Db::getWeight ( Id  iech) const

◆ getWeights()

gstlrn::Db::getWeights ( bool  useSel = false) const

◆ getWithinBounds()

gstlrn::Db::getWithinBounds ( Id  item,
bool  useSel = false 
) const

◆ getZVariable()

double gstlrn::Db::getZVariable ( Id  iech,
Id  item 
) const

◆ hasLargerDimension()

bool gstlrn::Db::hasLargerDimension ( const Db dbaux) const

Check if the Space Dimension of 'dbaux' is larger (or equal) than the one of 'this'

Parameters
dbauxSecond Db
Returns

◆ hasLocator()

bool gstlrn::Db::hasLocator ( const ELoc &  locatorType) const

◆ hasLocatorDefined()

bool gstlrn::Db::hasLocatorDefined ( const String name,
const ELoc &  locatorType,
Id  locatorIndex = 0 
) const

Check if a variable (specified by its name) matches the required locator

Parameters
nameName of the target Variable
locatorTypeCharacteristics of the required Locator Type
locatorIndexIndex of the required Locator (or -1)
Returns

◆ hasSameDimension()

bool gstlrn::Db::hasSameDimension ( const Db dbaux) const

◆ hasZVariable()

bool gstlrn::Db::hasZVariable ( ) const

◆ isActive()

bool gstlrn::Db::isActive ( Id  iech) const

◆ isActiveAndDefined()

bool gstlrn::Db::isActiveAndDefined ( Id  iech,
Id  item 
) const

◆ isActiveDomain()

bool gstlrn::Db::isActiveDomain ( Id  iech) const

◆ isAllIsotopic()

bool gstlrn::Db::isAllIsotopic ( ) const

Check that all the active samples are isotopic

◆ isAllUndefined()

bool gstlrn::Db::isAllUndefined ( Id  iech) const

◆ isAllUndefinedByType()

bool gstlrn::Db::isAllUndefinedByType ( const ELoc &  loctype,
Id  iech 
) const

◆ isConsistent()

virtual bool gstlrn::Db::isConsistent ( ) const
inlinevirtual

◆ isGrid()

virtual bool gstlrn::Db::isGrid ( ) const
inlinevirtual

Interface for Db.

Reimplemented in gstlrn::DbGrid.

◆ isIsotopic()

bool gstlrn::Db::isIsotopic ( Id  iech,
Id  nvar_max = -1 
) const

Check if the information (ELOC.Z) for a sample is isotopic or not Isotopic says that all variables (for this sample) are defined

Parameters
iechRank of the sample
nvar_maxMaximum number of variables to be checked (or -1)
Remarks
The returned answer is false is there is no variable defined or if the sample rank is not valid. If 'nvar_max' is defined, the test is performed on the 'nvar_max' first variables. Otherwise, it is performed on all ELOC.Z variables

◆ isLine()

virtual bool gstlrn::Db::isLine ( ) const
inlinevirtual

Reimplemented in gstlrn::DbGraphO, and gstlrn::DbLine.

◆ isMesh()

virtual bool gstlrn::Db::isMesh ( ) const
inlinevirtual

◆ isNVarComparedTo()

bool gstlrn::Db::isNVarComparedTo ( Id  nvar,
Id  compare = 0 
) const

Checks the number of variables in 'this' compared to the required 'nvar'

  • compare=0: they should be equal
  • compare<0: 'this' should contain less (or equal) than 'nvar'
  • compare>0: 'this' should contain more (or equal) than 'nvar'

◆ isUIDDefined()

bool gstlrn::Db::isUIDDefined ( Id  iuid) const

◆ mayChangeSampleNumber()

virtual bool gstlrn::Db::mayChangeSampleNumber ( ) const
inlinevirtual

◆ operator=()

Db & gstlrn::Db::operator= ( const Db r)

◆ printOneSample()

Table gstlrn::Db::printOneSample ( Id  iech,
const VectorString names = VectorString(),
bool  excludeCoordinates = true,
bool  skipTitle = false 
) const

◆ resetDims()

void gstlrn::Db::resetDims ( Id  ncol,
Id  nech 
)
virtual

Reimplemented in gstlrn::DbGrid.

◆ setAllColumns()

void gstlrn::Db::setAllColumns ( const 1 &  tabs)

Setting the contents of all the Columns of a Db

Parameters
tabsVector of vectors containing the values to be assigned

◆ setArray()

void gstlrn::Db::setArray ( Id  iech,
Id  iuid,
double  value 
)

Set the value by Sample and UID

Parameters
iechIndex of the Sample
iuidIndex of the UID
valueValue to be assigned

◆ setArrayBySample()

void gstlrn::Db::setArrayBySample ( Id  iech,
const 1 &  vec 
)

◆ setArrayByUID()

void gstlrn::Db::setArrayByUID ( const 1 &  tab,
Id  iuid 
)

◆ setArrayVec()

void gstlrn::Db::setArrayVec ( const 1 &  iechs,
Id  iuid,
const 1 &  values 
)

Set the values of a series of samples

Parameters
iechsList of sample indices
iuidIndex of the UID
valuesList of values to be written
Remarks
: for efficiency purpose, no check is performed on the sample ranks

◆ setBound()

void gstlrn::Db::setBound ( Id  iech,
Id  item,
double  lower = TEST,
double  upper = TEST 
)

◆ setColumn()

void gstlrn::Db::setColumn ( const 1 &  tab,
const String name,
const ELoc &  locatorType = ELoc::fromKey("UNKNOWN"),
Id  locatorIndex = 0,
bool  useSel = false 
)

Set the values for an already existing Column. Note that, if the Column does not exist, this Column is added beforehand

Parameters
tabArray of values to be stored in the target Column
nameName of the Column
locatorTypeLocator type
locatorIndexLocator index (starting from 0)
useSelShould an already existing Selection be taken into account
Remarks
: Arguments 'locatorType' and 'locatorIndex' are only used
: for newly added variables

◆ setColumnByColIdx()

void gstlrn::Db::setColumnByColIdx ( const 1 &  tab,
Id  icol,
bool  useSel = false 
)

◆ setColumnByColIdxOldStyle()

void gstlrn::Db::setColumnByColIdxOldStyle ( const double *  tab,
Id  icol,
bool  useSel = false 
)

◆ setColumnByUID()

void gstlrn::Db::setColumnByUID ( const 1 &  tab,
Id  iuid,
bool  useSel = false 
)

◆ setColumnByUIDOldStyle()

void gstlrn::Db::setColumnByUIDOldStyle ( const double *  tab,
Id  iuid,
bool  useSel = false 
)

Update the contents of an already existing variable in a Db

Parameters
tabVector containing the values to be written
iuidUID of the already existing variable to be written
useSelWhen TRUE, take the Selection into account (seed remarks)
Remarks
When useSel=TRUE, the input vector should be dimensioned to
the number of active samples. Only the active samples of the Db
are updated using the contents of the input 'tab' vector.

◆ setColumnsByColIdx()

void gstlrn::Db::setColumnsByColIdx ( const 1 &  tabs,
const 1 &  icols,
bool  useSel = false 
)

◆ setCoordinate()

void gstlrn::Db::setCoordinate ( Id  iech,
Id  idim,
double  value 
)

◆ setCoordinates()

void gstlrn::Db::setCoordinates ( Id  idim,
const 1 &  coor,
bool  useSel = false 
)

◆ setFromLocator()

void gstlrn::Db::setFromLocator ( const ELoc &  locatorType,
Id  iech,
Id  locatorIndex,
double  value 
)

◆ setInterval()

void gstlrn::Db::setInterval ( Id  iech,
Id  item,
double  rklow = TEST,
double  rkup = TEST 
)

◆ setItem() [1/6]

Id gstlrn::Db::setItem ( const 1 &  rows,
const ELoc &  locatorType,
const 1 &  values,
bool  useSel = false 
)

◆ setItem() [2/6]

Id gstlrn::Db::setItem ( const 1 &  rows,
const String colname,
const 1 &  values,
bool  useSel = false 
)

◆ setItem() [3/6]

Id gstlrn::Db::setItem ( const 1 &  rows,
const VectorString colnames,
const 1 &  values,
bool  useSel = false 
)

◆ setItem() [4/6]

Id gstlrn::Db::setItem ( const ELoc &  locatorType,
const 1 &  values,
bool  useSel = false 
)

◆ setItem() [5/6]

Id gstlrn::Db::setItem ( const String colname,
const 1 &  values,
bool  useSel = false 
)

◆ setItem() [6/6]

Id gstlrn::Db::setItem ( const VectorString colnames,
const 1 &  values,
bool  useSel = false 
)

◆ setLocator()

void gstlrn::Db::setLocator ( const String name,
const ELoc &  locatorType = ELoc::fromKey("UNKNOWN"),
Id  locatorIndex = 0,
bool  cleanSameLocator = false 
)

Define the Locator(s) for the given variable(s)

Parameters
nameVariable name
locatorTypeLocator Type
locatorIndexLocator Index (for the first variable) (starting from 0)
cleanSameLocatorWhen TRUE, clean variables with same locator beforehand

◆ setLocatorByColIdx()

void gstlrn::Db::setLocatorByColIdx ( Id  icol,
const ELoc &  locatorType = ELoc::fromKey("UNKNOWN"),
Id  locatorIndex = 0,
bool  cleanSameLocator = false 
)

◆ setLocatorByUID()

void gstlrn::Db::setLocatorByUID ( Id  iuid,
const ELoc &  locatorType = ELoc::fromKey("UNKNOWN"),
Id  locatorIndex = 0,
bool  cleanSameLocator = false 
)

Setting the locator for a variable designated by its UID

Parameters
iuidIndex of the UID
locatorTypeType of locator (include ELoc::UNKNOWN)
locatorIndexRank in the Locator (starting from 0)
cleanSameLocatorWhen TRUE, clean variables with same locator beforehand
Remarks
: 1) At this stage, no check is performed to see if items
: are consecutive and all defined. This allow using this function in any order.
: Argument 'locatorIndex' can be set to a negative value: in that case,
: the next index of the same 'locatorType' is generated automatically

◆ setLocators()

void gstlrn::Db::setLocators ( const VectorString names,
const ELoc &  locatorType = ELoc::fromKey("UNKNOWN"),
Id  locatorIndex = 0,
bool  cleanSameLocator = false 
)

Setting the locator for a set of variables designated by their names

Parameters
namesVector of variable names
locatorTypeLocator type (include ELoc::UNKNOWN)
locatorIndexStarting locator rank (starting from 0)
cleanSameLocatorWhen TRUE, clean variables with same locator beforehand

◆ setLocatorsByColIdx()

void gstlrn::Db::setLocatorsByColIdx ( const 1 &  icols,
const ELoc &  locatorType = ELoc::fromKey("UNKNOWN"),
Id  locatorIndex = 0,
bool  cleanSameLocator = false 
)

◆ setLocatorsByUID() [1/2]

void gstlrn::Db::setLocatorsByUID ( const 1 &  iuids,
const ELoc &  locatorType = ELoc::fromKey("UNKNOWN"),
Id  locatorIndex = 0,
bool  cleanSameLocator = false 
)

◆ setLocatorsByUID() [2/2]

void gstlrn::Db::setLocatorsByUID ( Id  number,
Id  iuid,
const ELoc &  locatorType = ELoc::fromKey("UNKNOWN"),
Id  locatorIndex = 0,
bool  cleanSameLocator = false 
)

Set the Locators for a set of variables identified by their UID

Parameters
numberNumber of variables to be set
iuidIndex of the first UID
locatorTypeType of the Locator (include ELoc::UNKNOWN)
locatorIndexRank of the first Locator index (starting from 0)
cleanSameLocatorWhen TRUE, clean variables with same locator beforehand

◆ setLocVariables()

void gstlrn::Db::setLocVariables ( const ELoc &  loctype,
Id  iech,
const 1 &  values 
)

◆ setSampleCoordinates()

void gstlrn::Db::setSampleCoordinates ( Id  iech,
const 1 &  coor 
)

◆ setValue()

void gstlrn::Db::setValue ( const String name,
Id  iech,
double  value 
)

Sets the value of the 'iech' sample of the variable 'name'

This function does not use 'ids' mechanism in order to allow referring to a non-existing variable

◆ setValueByColIdx()

void gstlrn::Db::setValueByColIdx ( Id  iech,
Id  icol,
double  value,
bool  flagCheck = true 
)

◆ setValuesByColIdx()

void gstlrn::Db::setValuesByColIdx ( const 1 &  iechs,
const 1 &  icols,
const 1 &  values,
bool  bySample = false 
)

◆ setValuesByNames()

void gstlrn::Db::setValuesByNames ( const 1 &  iechs,
const VectorString names,
const 1 &  values,
bool  bySample = false 
)

◆ setZVariable()

void gstlrn::Db::setZVariable ( Id  iech,
Id  item,
double  value 
)

◆ shrinkToValidCols()

gstlrn::Db::shrinkToValidCols ( const 1 &  cols) const

◆ shrinkToValidRows()

gstlrn::Db::shrinkToValidRows ( const 1 &  rows) const

◆ switchLocator()

void gstlrn::Db::switchLocator ( const ELoc &  locatorType_in,
const ELoc &  locatorType_out 
)

◆ toString()

String gstlrn::Db::toString ( const AStringFormat strfmt = nullptr) const
overridevirtual

◆ updArray()

void gstlrn::Db::updArray ( Id  iech,
Id  iuid,
const EOperator &  oper,
double  value 
)

◆ updArrayVec()

void gstlrn::Db::updArrayVec ( const 1 &  iechs,
Id  iuid,
const EOperator &  oper,
1 &  values 
)

◆ updZVariable()

void gstlrn::Db::updZVariable ( Id  iech,
Id  item,
const EOperator &  oper,
double  value 
)

Member Data Documentation

◆ DECLARE_TOTL

gstlrn::Db::DECLARE_TOTL

Has a specific implementation in the Target language.


The documentation for this class was generated from the following files: