gstlearn  1.0.0
CCC
ANeigh Class Referenceabstract

#include <ANeigh.hpp>

Inheritance diagram for ANeigh:
ASpaceObject ASerializable AStringable NeighBench NeighCell NeighImage NeighMoving NeighUnique

Public Member Functions

 ANeigh (const ASpace *space=nullptr)
 
 ANeigh (const ANeigh &r)
 
ANeighoperator= (const ANeigh &r)
 
virtual ~ANeigh ()
 
virtual bool isConsistent (const ASpace *space) const override
 ASpaceObject Interface. More...
 
virtual int attach (const Db *dbin, const Db *dbout)
 Interface for ANeigh. More...
 
virtual VectorInt getNeigh (int iech_out)=0
 
virtual int getMaxSampleNumber (const Db *db) const =0
 
virtual bool hasChanged (int iech_out) const
 
virtual VectorDouble summary (int iech_out)
 
virtual ENeigh getType () const
 
virtual bool getFlagContinuous () const
 
VectorInt select (int iech_out)
 
bool isUnchanged () const
 
void setIsChanged ()
 
void reset ()
 
bool getFlagXvalid () const
 
bool getFlagKFold () const
 
void setFlagXvalid (bool flagXvalid)
 
void setFlagKFold (bool flagKFold)
 
void setFlagSimu (bool flagSimu)
 
void setRankColCok (const VectorInt &rankColCok)
 
- Public Member Functions inherited from ASpaceObject
 ASpaceObject (const ASpace *space=nullptr)
 
 ASpaceObject (const ASpace &space)
 
 ASpaceObject (const ASpaceObject &r)
 
ASpaceObjectoperator= (const ASpaceObject &r)
 
virtual ~ASpaceObject ()
 
virtual String toString (const AStringFormat *strfmt=nullptr) const override
 AStringable interface. More...
 
const ASpacegetSpace () const
 Accessor to the current object space context. More...
 
bool isConsistent () const
 Indicate if I am consistent with my current space context. More...
 
VectorDouble getUnitaryVector () const
 Return unitary vector for the current space context. More...
 
unsigned int getNDim () const
 Shortcuts to ASpace methods. More...
 
const VectorDoublegetOrigin () const
 Return the current space context origin coordinates. More...
 
double getDistance (const SpacePoint &p1, const SpacePoint &p2) const
 Return the distance between two space points for the current space context. More...
 
double getDistance1D (const SpacePoint &p1, const SpacePoint &p2, int idim) const
 Return the distance along one direction between two space points. More...
 
VectorDouble getIncrement (const SpacePoint &p1, const SpacePoint &p2) const
 Return the increment vector between two space points for the current space context. More...
 
- Public Member Functions inherited from AStringable
 AStringable ()
 
 AStringable (const AStringable &r)
 
AStringableoperator= (const AStringable &r)
 
virtual ~AStringable ()
 
virtual void display (const AStringFormat *strfmt=nullptr) const final
 
virtual void display (int level) const final
 
- Public Member Functions inherited from ASerializable
 ASerializable ()
 
 ASerializable (const ASerializable &r)
 
ASerializableoperator= (const ASerializable &r)
 
virtual ~ASerializable ()
 
bool deserialize (std::istream &is, bool verbose=true)
 
bool serialize (std::ostream &os, bool verbose=true) const
 
bool dumpToNF (const String &neutralFilename, bool verbose=false) const
 

Protected Member Functions

bool _isNbghMemoEmpty () const
 
void _neighCompress (VectorInt &ranks)
 
void _display (const VectorInt &ranks)
 
bool _discardUndefined (int iech)
 
int _xvalid (int iech_in, int iech_out, double eps=EPSILON9)
 
bool _isDimensionValid (int idim) const
 
virtual bool _deserialize (std::istream &is, bool verbose=false) override
 
virtual bool _serialize (std::ostream &os, bool verbose=false) const override
 
String _getNFName () const override
 
- Protected Member Functions inherited from ASpaceObject
void setNDim (int ndim)
 Modify the Space dimension of an already created item (To be used only during creation ... in particular when reading NF) More...
 
- Protected Member Functions inherited from ASerializable
bool _fileOpenWrite (const String &filename, std::ofstream &os, bool verbose=false) const
 
bool _fileOpenRead (const String &filename, std::ifstream &is, bool verbose=false) const
 

Protected Attributes

const Db_dbin
 
const Db_dbout
 
const DbGrid_dbgrid
 
VectorInt _rankColCok
 
int _iechMemo
 
bool _flagSimu
 
bool _flagXvalid
 
bool _flagKFold
 
- Protected Attributes inherited from ASpaceObject
const ASpace_space
 Current space context of the object. More...
 

Private Member Functions

bool _isSameTarget (int iech_out)
 
void _checkUnchanged (int iech_out, const VectorInt &ranks)
 
void _updateColCok (VectorInt &ranks, int iech_out)
 

Private Attributes

bool _flagIsUnchanged
 
VectorInt _nbghMemo
 

Additional Inherited Members

- Static Public Member Functions inherited from ASerializable
static String buildFileName (int status, const String &filename, bool ensureDirExist=false)
 
static String getHomeDirectory (const String &sub="")
 
static String getWorkingDirectory ()
 
static String getTestData (const String &subdir, const String &filename)
 
static String getFileIdentity (const String &filename, bool verbose=false)
 
static void setContainerName (bool useDefault, const String &containerName="", bool verbose=false)
 
static void unsetContainerName ()
 
static void setPrefixName (const String &prefixName)
 
static void unsetPrefixName ()
 
static const StringgetContainerName ()
 
static const StringgetPrefixName ()
 
static bool createDirectory (const String &dir)
 
static String getExecDirectory ()
 
static String getDirectory (const String &path)
 
- Static Protected Member Functions inherited from ASerializable
static bool _commentWrite (std::ostream &os, const String &comment)
 
template<typename T >
static bool _recordWrite (std::ostream &os, const String &title, const T &val)
 
template<typename T >
static bool _recordWriteVec (std::ostream &os, const String &title, const VectorT< T > &vec)
 
template<typename T >
static bool _recordRead (std::istream &is, const String &title, T &val)
 
template<typename T >
static bool _recordReadVec (std::istream &is, const String &title, VectorT< T > &vec, int nvalues)
 
static bool _onlyBlanks (char *string)
 
static bool _tableRead (std::istream &is, const String &string, int ntab, double *tab)
 
static bool _tableWrite (std::ostream &os, const String &string, int ntab, const VectorDouble &tab)
 

Constructor & Destructor Documentation

◆ ANeigh() [1/2]

ANeigh::ANeigh ( const ASpace space = nullptr)

◆ ANeigh() [2/2]

ANeigh::ANeigh ( const ANeigh r)

◆ ~ANeigh()

ANeigh::~ANeigh ( )
virtual

Member Function Documentation

◆ _checkUnchanged()

void ANeigh::_checkUnchanged ( int  iech_out,
const VectorInt ranks 
)
private

◆ _deserialize()

bool ANeigh::_deserialize ( std::istream &  is,
bool  verbose = false 
)
overrideprotectedvirtual

Implements ASerializable.

Reimplemented in NeighUnique, NeighMoving, NeighImage, NeighCell, and NeighBench.

◆ _discardUndefined()

bool ANeigh::_discardUndefined ( int  iech)
protected

Discard a sample for which all variables are undefined

Returns 1 if all variables are undefined; 0 otherwise

Parameters
[in]iechRank of the sample
Remarks
When the Neighborhood is performed in the case of Simulations
checking for all variables being undefined is performed
on ELoc::SIMU rather than on ELoc::Z

◆ _display()

void ANeigh::_display ( const VectorInt ranks)
protected

Print the information selected in the neighborhood

Parameters
[in]ranksArray of the data ranks
  • -1 if not selected
  • >=0 gives the angular sector in ENeigh::MOVING

◆ _getNFName()

String ANeigh::_getNFName ( ) const
inlineoverrideprotectedvirtual

Implements ASerializable.

Reimplemented in NeighUnique, NeighMoving, NeighImage, NeighCell, and NeighBench.

◆ _isDimensionValid()

bool ANeigh::_isDimensionValid ( int  idim) const
protected

◆ _isNbghMemoEmpty()

bool ANeigh::_isNbghMemoEmpty ( ) const
inlineprotected

◆ _isSameTarget()

bool ANeigh::_isSameTarget ( int  iech_out)
private

Checks if the current target matches the target previously treated in the same procedure. If match is reached, then there is no need to compute a new neighborhood: use the previous Vector of sample ranks. Store the references of the new 'dbout' and 'iech_out' for next optimizations

Parameters
iech_outRank of the current target sample
Returns

◆ _neighCompress()

void ANeigh::_neighCompress ( VectorInt ranks)
protected

◆ _serialize()

bool ANeigh::_serialize ( std::ostream &  os,
bool  verbose = false 
) const
overrideprotectedvirtual

Implements ASerializable.

Reimplemented in NeighUnique, NeighMoving, NeighImage, NeighCell, and NeighBench.

◆ _updateColCok()

void ANeigh::_updateColCok ( VectorInt ranks,
int  iech_out 
)
private

Update the set of selected samples in case of colocated option This is done only if:

  • the colocation option is ON (vector of colocated variable is defined)
  • at least one of the colocated variables at the target is valid
  • the target does not coincide with a sample already selected If the colocation option is validated, an additional member is added to 'ranks': its value is conventionally set to -1.
    Parameters
    ranksVector of samples already selected
    iech_outRank of the target site (in dbout)

◆ _xvalid()

int ANeigh::_xvalid ( int  iech_in,
int  iech_out,
double  eps = EPSILON9 
)
protected

Mask the data sample in the case of cross-validation

Returns
1 if the sample is masked; 0 otherwise
Parameters
[in]iech_inRank in the input Db structure
[in]iech_outRank in the output Db structure
[in]epsTolerance

◆ attach()

int ANeigh::attach ( const Db dbin,
const Db dbout 
)
virtual

Interface for ANeigh.

Reimplemented in NeighMoving, NeighCell, and NeighBench.

◆ getFlagContinuous()

virtual bool ANeigh::getFlagContinuous ( ) const
inlinevirtual

Reimplemented in NeighMoving.

◆ getFlagKFold()

bool ANeigh::getFlagKFold ( ) const
inline

◆ getFlagXvalid()

bool ANeigh::getFlagXvalid ( ) const
inline

◆ getMaxSampleNumber()

virtual int ANeigh::getMaxSampleNumber ( const Db db) const
pure virtual

◆ getNeigh()

virtual VectorInt ANeigh::getNeigh ( int  iech_out)
pure virtual

◆ getType()

virtual ENeigh ANeigh::getType ( ) const
inlinevirtual

◆ hasChanged()

virtual bool ANeigh::hasChanged ( int  iech_out) const
inlinevirtual

◆ isConsistent()

virtual bool ANeigh::isConsistent ( const ASpace space) const
inlineoverridevirtual

ASpaceObject Interface.

Implements ASpaceObject.

◆ isUnchanged()

bool ANeigh::isUnchanged ( ) const
inline

◆ operator=()

ANeigh & ANeigh::operator= ( const ANeigh r)

◆ reset()

void ANeigh::reset ( )

◆ select()

VectorInt ANeigh::select ( int  iech_out)

◆ setFlagKFold()

void ANeigh::setFlagKFold ( bool  flagKFold)
inline

◆ setFlagSimu()

void ANeigh::setFlagSimu ( bool  flagSimu)
inline

◆ setFlagXvalid()

void ANeigh::setFlagXvalid ( bool  flagXvalid)
inline

◆ setIsChanged()

void ANeigh::setIsChanged ( )

◆ setRankColCok()

void ANeigh::setRankColCok ( const VectorInt rankColCok)
inline

◆ summary()

virtual VectorDouble ANeigh::summary ( int  iech_out)
inlinevirtual

Reimplemented in NeighMoving.

Member Data Documentation

◆ _dbgrid

const DbGrid* ANeigh::_dbgrid
protected

◆ _dbin

const Db* ANeigh::_dbin
protected

◆ _dbout

const Db* ANeigh::_dbout
protected

◆ _flagIsUnchanged

bool ANeigh::_flagIsUnchanged
private

◆ _flagKFold

bool ANeigh::_flagKFold
protected

◆ _flagSimu

bool ANeigh::_flagSimu
protected

◆ _flagXvalid

bool ANeigh::_flagXvalid
protected

◆ _iechMemo

int ANeigh::_iechMemo
protected

◆ _nbghMemo

VectorInt ANeigh::_nbghMemo
mutableprivate

◆ _rankColCok

VectorInt ANeigh::_rankColCok
protected

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