gstlearn  1.0.0
CCC
ShiftOpCs Class Reference

Shift Operator for performing the basic tasks of SPDE. More...

#include <ShiftOpCs.hpp>

Inheritance diagram for ShiftOpCs:
ALinearOp

Public Member Functions

 ShiftOpCs (const CGParam params=CGParam())
 
 ShiftOpCs (const AMesh *amesh, Model *model, const Db *dbout=nullptr, int igrf=0, int icov=0, const CGParam params=CGParam(), bool verbose=false)
 
 ShiftOpCs (const cs *S, const VectorDouble &TildeC, const VectorDouble &Lambda, Model *model, const CGParam params=CGParam(), bool verbose=false)
 
 ShiftOpCs (const ShiftOpCs &shift)
 
ShiftOpCsoperator= (const ShiftOpCs &shift)
 
virtual ~ShiftOpCs ()
 
void _evalDirect (const VectorDouble &inv, VectorDouble &outv) const override
 
int initFromMesh (const AMesh *amesh, Model *model, const Db *dbout=nullptr, int igrf=0, int icov=0, bool flagAdvection=false, bool verbose=false)
 
int initGradFromMesh (const AMesh *amesh, Model *model, int igrf=0, int icov=0, bool verbose=false, double tol=EPSILON10)
 
int initFromCS (const cs *S, const VectorDouble &TildeC, const VectorDouble &Lambda, Model *model, bool verbose=false)
 
int getSize () const override
 
int getNDim () const
 
int getNModelGradParam () const
 
void prodTildeC (const VectorDouble &x, VectorDouble &y, const EPowerPT &power) const
 
void prodLambda (const VectorDouble &x, VectorDouble &y, const EPowerPT &power) const
 
void prodLambdaOnSqrtTildeC (const VectorDouble &inv, VectorDouble &outv, double puis=2) const
 
double getMaxEigenValue () const
 
cs * getS () const
 
cs * getTildeCGrad (int iapex, int igparam) const
 
cs * getSGrad (int iapex, int igparam) const
 
Triplet getSToTriplet (bool flag_from_1=false) const
 
Triplet getTildeCGradToTriplet (int iapex, int igparam, bool flag_from_1=false) const
 
Triplet getSGradToTriplet (int iapex, int igparam, bool flag_from_1=false) const
 
const VectorDoublegetTildeC () const
 
const VectorDoublegetLambdas () const
 
double getLambda (int iapex) const
 
const VectorDoublegetLambdaGrads (int idim) const
 
double getLambdaGrad (int idim, int iapex) const
 
int getSGradAddress (int iapex, int igparam) const
 
int getLambdaGradSize () const
 
- Public Member Functions inherited from ALinearOp
 ALinearOp (const CGParam params=CGParam())
 
 ALinearOp (const ALinearOp &m)
 
ALinearOpoperator= (const ALinearOp &m)
 
virtual ~ALinearOp ()
 
virtual void evalInverse (const VectorDouble &inv, VectorDouble &outv) const
 
void evalDirect (const VectorDouble &inv, VectorDouble &outv) const
 
void setX0 (const VectorDouble &x0)
 
void mustShowStats (bool status)
 
const LogStatsgetLogStats () const
 

Static Public Member Functions

static ShiftOpCscreate (const AMesh *amesh, Model *model, const Db *dbout=nullptr, int igrf=0, int icov=0, const CGParam params=CGParam(), bool verbose=false)
 
static ShiftOpCscreateFromSparse (const cs *S, const VectorDouble &TildeC, const VectorDouble &Lambda, Model *model, const CGParam params=CGParam(), bool verbose=false)
 

Private Member Functions

int _getIcov () const
 
void _setIcov (int icov)
 
int _getIgrf () const
 
void _setIgrf (int igrf)
 
const Model_getModel () const
 
void _setModel (const Model *model)
 
bool _isNoStat ()
 
bool _isGlobalHH (int igrf, int icov)
 
const CovAniso_getCova ()
 
int _buildS (const AMesh *amesh, double tol=EPSILON10)
 
int _buildSGrad (const AMesh *amesh, double tol=EPSILON10)
 
void _buildLambda (const AMesh *amesh)
 
void _loadAux (VectorDouble &tab, const EConsElem &type, int imesh=0)
 
void _loadHH (const AMesh *amesh, MatrixSquareSymmetric &hh, int imesh=0)
 
void _loadHHRegular (MatrixSquareSymmetric &hh, int imesh)
 
void _loadHHVariety (MatrixSquareSymmetric &hh, int imesh)
 
void _loadHHGrad (const AMesh *amesh, MatrixSquareSymmetric &hh, int igparam, int ipref)
 
double _computeGradLogDetHH (const AMesh *amesh, int igparam, int ipref, const MatrixSquareSymmetric &HH, MatrixSquareSymmetric &work, MatrixSquareSymmetric &work2)
 
bool _buildLambdaGrad (const AMesh *amesh)
 
void _reset ()
 
void _resetGrad ()
 
void _reallocate (const ShiftOpCs &shift)
 
void _projectMesh (const AMesh *amesh, const VectorDouble &srot, int imesh, double coeff[3][2])
 
int _preparMatrices (const AMesh *amesh, int imesh, MatrixSquareGeneral &matu, MatrixRectangular &matw) const
 
int _prepareMatricesSVariety (const AMesh *amesh, int imesh, VectorVectorDouble &coords, MatrixSquareSymmetric &matMtM, AMatrix &matres, double *deter)
 
int _prepareMatricesSphere (const AMesh *amesh, int imesh, VectorVectorDouble &coords, AMatrixSquare &matres, double *deter)
 
void _updateCova (CovAniso *cova, int imesh)
 
VectorT< std::map< int, double > > _mapCreate () const
 
VectorT< VectorT< std::map< int, double > > > _mapVectorCreate () const
 
VectorT< std::map< int, double > > _mapTildeCCreate () const
 
void _mapTildeCUpdate (std::map< int, double > &tab, int ip1, double value, double tol=EPSILON10) const
 
void _mapGradUpdate (std::map< std::pair< int, int >, double > &tab, int ip0, int ip1, double value, double tol=EPSILON10)
 
cs * _BuildTildeCGradfromMap (std::map< int, double > &tab) const
 
cs * _BuildSGradfromMap (std::map< std::pair< int, int >, double > &tab)
 
bool _cond (int indref, int igparam, int ipref)
 
void _determineFlagNoStatByHH ()
 
void _updateHH (MatrixSquareSymmetric &hh, int imesh)
 
cs * _preparSSparse (const AMesh *amesh) const
 

Private Attributes

VectorDouble _TildeC
 
VectorDouble _Lambda
 
cs * _S
 
int _nModelGradParam
 
VectorT< cs * > _SGrad
 
VectorT< cs * > _TildeCGrad
 
VectorVectorDouble _LambdaGrad
 
bool _flagNoStatByHH
 
const Model_model
 
int _igrf
 
int _icov
 
int _ndim
 
int _napices
 

Additional Inherited Members

- Protected Attributes inherited from ALinearOp
LogStats _logStats
 

Detailed Description

Shift Operator for performing the basic tasks of SPDE.

Constructor & Destructor Documentation

◆ ShiftOpCs() [1/4]

ShiftOpCs::ShiftOpCs ( const CGParam  params = CGParam())

◆ ShiftOpCs() [2/4]

ShiftOpCs::ShiftOpCs ( const AMesh amesh,
Model model,
const Db dbout = nullptr,
int  igrf = 0,
int  icov = 0,
const CGParam  params = CGParam(),
bool  verbose = false 
)

◆ ShiftOpCs() [3/4]

ShiftOpCs::ShiftOpCs ( const cs *  S,
const VectorDouble TildeC,
const VectorDouble Lambda,
Model model,
const CGParam  params = CGParam(),
bool  verbose = false 
)

◆ ShiftOpCs() [4/4]

ShiftOpCs::ShiftOpCs ( const ShiftOpCs shift)

◆ ~ShiftOpCs()

ShiftOpCs::~ShiftOpCs ( )
virtual

Member Function Documentation

◆ _buildLambda()

void ShiftOpCs::_buildLambda ( const AMesh amesh)
private

Construct the _Lambda vector (Dimension: _napices)

Parameters
ameshDescription of the Mesh

◆ _buildLambdaGrad()

bool ShiftOpCs::_buildLambdaGrad ( const AMesh amesh)
private

Construct the _Lambda vector (Dimension: _napices)

Parameters
ameshDescription of the Mesh (New class)
Returns

◆ _buildS()

int ShiftOpCs::_buildS ( const AMesh amesh,
double  tol = EPSILON10 
)
private

Calculate the private member "_S" directly from the Mesh on a Variety in 3-D space

Parameters
ameshDescription of the Mesh (New class)
tolTolerance beyond which elements are not stored in S matrix
Returns
Error return code
Remarks
TildeC is calculated at the same time

◆ _buildSGrad()

int ShiftOpCs::_buildSGrad ( const AMesh amesh,
double  tol = EPSILON10 
)
private

Calculate the private member "_SGrad" directly from the Mesh

Parameters
ameshDescription of the Mesh (New class)
tolTolerance beyond which elements are not stored in S matrix
Returns
Error return code

◆ _BuildSGradfromMap()

cs * ShiftOpCs::_BuildSGradfromMap ( std::map< std::pair< int, int >, double > &  tab)
private

Transform the Map into a square cparse matrix

Parameters
tabInput Map
Returns

◆ _BuildTildeCGradfromMap()

cs * ShiftOpCs::_BuildTildeCGradfromMap ( std::map< int, double > &  tab) const
private

◆ _computeGradLogDetHH()

double ShiftOpCs::_computeGradLogDetHH ( const AMesh amesh,
int  igparam,
int  ipref,
const MatrixSquareSymmetric HH,
MatrixSquareSymmetric work,
MatrixSquareSymmetric work2 
)
private

◆ _cond()

bool ShiftOpCs::_cond ( int  indref,
int  igparam,
int  ipref 
)
private

◆ _determineFlagNoStatByHH()

void ShiftOpCs::_determineFlagNoStatByHH ( )
private

◆ _evalDirect()

void ShiftOpCs::_evalDirect ( const VectorDouble x,
VectorDouble y 
) const
overridevirtual

Perform the operation: y = S * x

Parameters
[in]xInput vector
[in]yOutput vector
Remarks
'S' is a member that stands as a sparse matrix

Implements ALinearOp.

◆ _getCova()

const CovAniso * ShiftOpCs::_getCova ( )
private

◆ _getIcov()

int ShiftOpCs::_getIcov ( ) const
inlineprivate

◆ _getIgrf()

int ShiftOpCs::_getIgrf ( ) const
inlineprivate

◆ _getModel()

const Model* ShiftOpCs::_getModel ( ) const
inlineprivate

◆ _isGlobalHH()

bool ShiftOpCs::_isGlobalHH ( int  igrf,
int  icov 
)
private

◆ _isNoStat()

bool ShiftOpCs::_isNoStat ( )
private

◆ _loadAux()

void ShiftOpCs::_loadAux ( VectorDouble tab,
const EConsElem &  type,
int  imesh = 0 
)
private

◆ _loadHH()

void ShiftOpCs::_loadHH ( const AMesh amesh,
MatrixSquareSymmetric hh,
int  imesh = 0 
)
private

Constitute HH (only in non-stationary case)

Parameters
hhReturned HH symmetric matrix
ameshPointer to the meshing
imeshRank of the mesh

◆ _loadHHGrad()

void ShiftOpCs::_loadHHGrad ( const AMesh amesh,
MatrixSquareSymmetric hh,
int  igparam,
int  ipref 
)
private

Calculate HH Gradient matrix from one of the Model parameters for the given Apex.

Parameters
ameshMeshing description (New format)
hhOutput Array (updated here)
igparamRank of the parameter for derivation
iprefRank of the point

: The parameters 'igparam' are sorted as follows:

: - 0:(ndim-1) : ranges in each Space direction

: - ndim:ngparam : rotation angles (=ndim or 1 in 2-D)

◆ _loadHHRegular()

void ShiftOpCs::_loadHHRegular ( MatrixSquareSymmetric hh,
int  imesh 
)
private

Calculate HH matrix from parameters Note that this function is also called in Stationary case... So it must be workable without any updates

Parameters
hhOutput Array
imeshRank of the active mesh

◆ _loadHHVariety()

void ShiftOpCs::_loadHHVariety ( MatrixSquareSymmetric hh,
int  imesh 
)
private

◆ _mapCreate()

VectorT< std::map< int, double > > ShiftOpCs::_mapCreate ( ) const
private

◆ _mapGradUpdate()

void ShiftOpCs::_mapGradUpdate ( std::map< std::pair< int, int >, double > &  tab,
int  ip0,
int  ip1,
double  value,
double  tol = EPSILON10 
)
private

◆ _mapTildeCCreate()

VectorT< std::map< int, double > > ShiftOpCs::_mapTildeCCreate ( ) const
private

◆ _mapTildeCUpdate()

void ShiftOpCs::_mapTildeCUpdate ( std::map< int, double > &  tab,
int  ip1,
double  value,
double  tol = EPSILON10 
) const
private

◆ _mapVectorCreate()

VectorT< VectorT< std::map< int, double > > > ShiftOpCs::_mapVectorCreate ( ) const
private

◆ _prepareMatricesSphere()

int ShiftOpCs::_prepareMatricesSphere ( const AMesh amesh,
int  imesh,
VectorVectorDouble coords,
AMatrixSquare matres,
double *  deter 
)
private

◆ _prepareMatricesSVariety()

int ShiftOpCs::_prepareMatricesSVariety ( const AMesh amesh,
int  imesh,
VectorVectorDouble coords,
MatrixSquareSymmetric matMtM,
AMatrix matres,
double *  deter 
)
private

◆ _preparMatrices()

int ShiftOpCs::_preparMatrices ( const AMesh amesh,
int  imesh,
MatrixSquareGeneral matu,
MatrixRectangular matw 
) const
private

◆ _preparSSparse()

cs * ShiftOpCs::_preparSSparse ( const AMesh amesh) const
private

◆ _projectMesh()

void ShiftOpCs::_projectMesh ( const AMesh amesh,
const VectorDouble srot,
int  imesh,
double  coeff[3][2] 
)
private

Project the coordinates of the mesh vertices on the sphere

Parameters
ameshMesh structure
srotRotation parameters
imeshRank of the mesh of interest
coeffCoordinates of the projected vertices

◆ _reallocate()

void ShiftOpCs::_reallocate ( const ShiftOpCs shift)
private

◆ _reset()

void ShiftOpCs::_reset ( )
private

◆ _resetGrad()

void ShiftOpCs::_resetGrad ( )
private

◆ _setIcov()

void ShiftOpCs::_setIcov ( int  icov)
inlineprivate

◆ _setIgrf()

void ShiftOpCs::_setIgrf ( int  igrf)
inlineprivate

◆ _setModel()

void ShiftOpCs::_setModel ( const Model model)
inlineprivate

◆ _updateCova()

void ShiftOpCs::_updateCova ( CovAniso cova,
int  imesh 
)
private

Locally update the covariance (does nothing in Stationary Case)

Parameters
covaLocal CovAniso structure (updated here)
imeshRank of the active mesh

◆ _updateHH()

void ShiftOpCs::_updateHH ( MatrixSquareSymmetric hh,
int  imesh 
)
private

◆ create()

ShiftOpCs * ShiftOpCs::create ( const AMesh amesh,
Model model,
const Db dbout = nullptr,
int  igrf = 0,
int  icov = 0,
const CGParam  params = CGParam(),
bool  verbose = false 
)
static

◆ createFromSparse()

ShiftOpCs * ShiftOpCs::createFromSparse ( const cs *  S,
const VectorDouble TildeC,
const VectorDouble Lambda,
Model model,
const CGParam  params = CGParam(),
bool  verbose = false 
)
static

◆ getLambda()

double ShiftOpCs::getLambda ( int  iapex) const
inline

◆ getLambdaGrad()

double ShiftOpCs::getLambdaGrad ( int  idim,
int  iapex 
) const
inline

◆ getLambdaGrads()

const VectorDouble& ShiftOpCs::getLambdaGrads ( int  idim) const
inline

◆ getLambdaGradSize()

int ShiftOpCs::getLambdaGradSize ( ) const

◆ getLambdas()

const VectorDouble& ShiftOpCs::getLambdas ( ) const
inline

◆ getMaxEigenValue()

double ShiftOpCs::getMaxEigenValue ( ) const

◆ getNDim()

int ShiftOpCs::getNDim ( ) const
inline

◆ getNModelGradParam()

int ShiftOpCs::getNModelGradParam ( ) const
inline

◆ getS()

cs* ShiftOpCs::getS ( ) const
inline

◆ getSGrad()

cs * ShiftOpCs::getSGrad ( int  iapex,
int  igparam 
) const

◆ getSGradAddress()

int ShiftOpCs::getSGradAddress ( int  iapex,
int  igparam 
) const

Returns the internal address for a given vertex and a given parameter It returns -1 if the address is ivalid

Parameters
iapexRank of the target apex
igparamRank of the target parameter
Returns

◆ getSGradToTriplet()

Triplet ShiftOpCs::getSGradToTriplet ( int  iapex,
int  igparam,
bool  flag_from_1 = false 
) const

◆ getSize()

int ShiftOpCs::getSize ( ) const
inlineoverridevirtual

Implements ALinearOp.

◆ getSToTriplet()

Triplet ShiftOpCs::getSToTriplet ( bool  flag_from_1 = false) const

◆ getTildeC()

const VectorDouble& ShiftOpCs::getTildeC ( ) const
inline

◆ getTildeCGrad()

cs * ShiftOpCs::getTildeCGrad ( int  iapex,
int  igparam 
) const

◆ getTildeCGradToTriplet()

Triplet ShiftOpCs::getTildeCGradToTriplet ( int  iapex,
int  igparam,
bool  flag_from_1 = false 
) const

◆ initFromCS()

int ShiftOpCs::initFromCS ( const cs *  S,
const VectorDouble TildeC,
const VectorDouble Lambda,
Model model,
bool  verbose = false 
)
Parameters
SSparse matrix describing the S information
TildeCDiagonal array containing TildeC
LambdaNormalization vector
modelPointer to the Model structure
verboseVerbose flag
Returns

◆ initFromMesh()

int ShiftOpCs::initFromMesh ( const AMesh amesh,
Model model,
const Db dbout = nullptr,
int  igrf = 0,
int  icov = 0,
bool  flagAdvection = false,
bool  verbose = false 
)
Parameters
ameshMeshing description (New format)
modelPointer to the Model structure
dboutPointer to the Db structure
igrfRank of the GRF
icovRank of the Covariance within the Model
flagAdvectionWhen TRUE, S is replaced by G
verboseVerbose flag
Returns
Error return code

◆ initGradFromMesh()

int ShiftOpCs::initGradFromMesh ( const AMesh amesh,
Model model,
int  igrf = 0,
int  icov = 0,
bool  verbose = false,
double  tol = EPSILON10 
)

Initialize the environment for calculation of derivatives of S

Parameters
ameshMeshing description (New format)
modelPointer to the Model structure
igrfRank of the GRF
icovRank of the Covariance within the Model
verboseVerbose flag
tolSmallest value below which the value is not stored in sparse matrix
Returns
Error return code

◆ operator=()

ShiftOpCs & ShiftOpCs::operator= ( const ShiftOpCs shift)

◆ prodLambda()

void ShiftOpCs::prodLambda ( const VectorDouble x,
VectorDouble y,
const EPowerPT &  power 
) const

◆ prodLambdaOnSqrtTildeC()

void ShiftOpCs::prodLambdaOnSqrtTildeC ( const VectorDouble inv,
VectorDouble outv,
double  puis = 2 
) const

◆ prodTildeC()

void ShiftOpCs::prodTildeC ( const VectorDouble x,
VectorDouble y,
const EPowerPT &  power 
) const

Perform the operation: y = x * C^power

Parameters
[in]xInput vector
[in]yOutput vector
[in]powerValue of the exponent
Remarks
'C' is a member (_TildeC) that stands as a vector
Specific coding has been realized for the cases
where 'power' is equal to 1, -1, 0.5 and -0.5

Member Data Documentation

◆ _flagNoStatByHH

bool ShiftOpCs::_flagNoStatByHH
private

◆ _icov

int ShiftOpCs::_icov
private

◆ _igrf

int ShiftOpCs::_igrf
private

◆ _Lambda

VectorDouble ShiftOpCs::_Lambda
private

◆ _LambdaGrad

VectorVectorDouble ShiftOpCs::_LambdaGrad
private

◆ _model

const Model* ShiftOpCs::_model
private

◆ _napices

int ShiftOpCs::_napices
private

◆ _ndim

int ShiftOpCs::_ndim
private

◆ _nModelGradParam

int ShiftOpCs::_nModelGradParam
private

◆ _S

cs* ShiftOpCs::_S
private

◆ _SGrad

VectorT<cs *> ShiftOpCs::_SGrad
private

◆ _TildeC

VectorDouble ShiftOpCs::_TildeC
private

◆ _TildeCGrad

VectorT<cs *> ShiftOpCs::_TildeCGrad
private

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