UQTk: Uncertainty Quantification Toolkit 3.1.5
|
Defines and initializes PC basis function set and provides functions to manipulate PC expansions defined on this basis set. More...
#include <PCSet.h>
Public Member Functions | |
PCSet (const string sp_type, const int order, const int n_dim, const string pc_type, const double alpha=0.0, const double betta=1.0) | |
Constructor: initializes the PC basis set for the order, number of dimensions and type that are passed in. | |
PCSet (const string sp_type, const int order, const int n_dim, const string pc_type, const string pc_seq, const double alpha=0.0, const double betta=1.0) | |
Constructor: initializes the PC basis set for the order, number of dimensions and type that are passed in. It also customizes the multiindex sequence ( lexicographical-lex, colexicographical-colex, reverse lexicographical-revlex, and reverse clexicographical-revcolex). | |
PCSet (const string sp_type, const Array1D< int > &maxOrders, const int n_dim, const string pc_type, const double alpha=0.0, const double betta=1.0) | |
Constructor: initializes the PC basis set ordered in an HDMR fashion given order per each HDMR rank (univariate, bivariate, etc...) | |
PCSet (const string sp_type, const Array2D< int > &customMultiIndex, const string pc_type, const double alpha=0.0, const double betta=1.0) | |
Constructor: initializes the PC basis set for a given custom multiIndex. | |
~PCSet () | |
Destructor: cleans up all memory and destroys object. | |
void | dPhi_alpha (Array1D< double > &x, Array1D< int > &alpha, Array1D< double > &grad) |
Set Gradient and Hessian operators. | |
void | dPhi (Array1D< double > &x, Array2D< int > &mindex, Array1D< double > &grad, Array1D< double > &ck) |
Evaluate Gradient at a single d-dim point. | |
void | dPhi (Array2D< double > &x, Array2D< int > &mindex, Array2D< double > &grad, Array1D< double > &ck) |
Evaluate Gradient at a multiple d-dim x points. | |
void | ddPhi_alpha (Array1D< double > &x, Array1D< int > &alpha, Array2D< double > &grad) |
Evaluate Hessian at a single d-dim point and d-dim basis polynomial. | |
void | ddPhi (Array1D< double > &x, Array2D< int > &mindex, Array2D< double > &grad, Array1D< double > &ck) |
Evaluate Gradient at a single d-dim point. | |
void | SetQd1d (Array1D< double > &qdpts1d, Array1D< double > &wghts1d, int nqd) |
Set the quadrature rule. | |
void | SetQuadRule (const string grid_type, const string fs_type, int param) |
Set the quadrature points by specifying a grid type, a full/sparse indicator, and an integer parameter. | |
void | SetQuadRule (Quad &quadRule) |
Set a custom quadrature rule by pointing to the corresponding object. | |
void | PrintMultiIndex () const |
Print information on the screen. | |
void | PrintMultiIndexNormSquared () const |
For all terms, print their multi-index and norm^2 on the screen. | |
string | GetPCType () const |
Get and set variables/arrays inline. | |
double | GetAlpha () const |
Get the value of the parameter alpha. | |
double | GetBeta () const |
Get the value of the parameter beta. | |
void | GetMultiIndex (Array2D< int > &mindex) const |
Get the multiindex (return Array2D) | |
void | GetMultiIndex (int *mindex) const |
Get the multiindex (return double *) | |
void | GetNormSq (Array1D< double > &normsq) const |
Get the norm-squared. | |
int | GetNumberPCTerms () const |
Get the number of terms in a PC expansion of this order and dimension. | |
int | GetNDim () const |
Get the PC dimensionality. | |
int | GetOrder () const |
Get the PC order. | |
int | GetNQuadPoints () const |
Get the number of quadrature points. | |
void | GetQuadPoints (Array2D< double > &quad) const |
Get the quadrature points. | |
void | GetQuadPointsWeights (Array2D< double > &quad, Array1D< double > &wghts) const |
Get the quadrature points and weights. | |
void | GetQuadPoints (double *quad) const |
Get the quadrature points folded into a one-dimensional array quad. | |
void | GetQuadWeights (Array1D< double > &wghts) const |
Get the quadrature weights. | |
void | GetQuadWeights (double *wghts) const |
Get the quadrature weights folded into a one-dimensional array wghts. | |
void | GetPsi (Array2D< double > &psi) const |
Get the values of the basis polynomials evaluated at the quadrature points. | |
void | GetPsi (double *psi) const |
Get the polynomials evaluated at the quadrature points folded into a one-dimensional array psi. | |
void | GetPsiSq (Array1D< double > &psisq) const |
Get the basis polynomial norms-squared in an array class object psisq. | |
void | GetPsiSq (double *psisq) const |
Get the basis polynomial norms-squared in a double* array psisq. | |
double | GetTaylorTolerance () const |
Get relative tolerance for Taylor series approximations. | |
void | SetTaylorTolerance (const double &rTol) |
Set relative tolerance for Taylor series approximations. | |
int | GetTaylorTermsMax () const |
Get maximum number of terms in Taylor series approximations. | |
void | SetTaylorTermsMax (const int &maxTerm) |
Set maximum number of terms in Taylor series approximations. | |
void | SetLogCompMethod (const LogCompMethod &logMethod) |
Set method of computing the log function. | |
double | GetGMRESDivTolerance () const |
Get relative tolerance for GMRES in Div routine. | |
void | SetGMRESDivTolerance (const double &rTol) |
Set the relative tolerance for GMRES in Div routine. | |
void | InitMeanStDv (const double &m, const double &s, double *p) const |
Intrusive arithmetics. | |
void | InitMeanStDv (const double &m, const double &s, Array1D< double > &p) const |
Initializes a PC expansion p in Array1D<double> format to have the same distribution as the underlying PC germ, but with a specified mean m and standard deviation s. | |
void | Copy (double *p1, const double *p2) const |
Copy PC expansion p2 into p1 (i.e. p1 = p2). | |
void | Copy (Array1D< double > &p1, const Array1D< double > &p2) const |
Copy PC expansion p2 into p1 (i.e. p1 = p2). | |
void | Add (const double *p1, const double *p2, double *p3) const |
Add two PC expansions given by double* arguments p1 and p2, and return the result in p3. | |
void | Add (const Array1D< double > &p1, const Array1D< double > &p2, Array1D< double > &p3) const |
Add two PC expansions given by Array1D arguments p1 and p2, and return the result in p3. | |
void | AddInPlace (double *p1, const double *p2) const |
Add PC expansions given by double* argument p2 to p1 and return the result in p1. | |
void | AddInPlace (Array1D< double > &p1, const Array1D< double > &p2) const |
Add PC expansions given by Array1D argument p2 to p1 and return the result in p1. | |
void | Multiply (const double *p1, const double &a, double *p2) const |
Multiply PC expansion p1 with scalar a and return the result in p2. All PCEs are in double* format. | |
void | Multiply (const Array1D< double > &p1, const double &a, Array1D< double > &p2) const |
Multiply PC expansion p1 with scalar a and return the result in p2. All PCEs are in Array1D format. | |
void | MultiplyInPlace (double *p1, const double &a) const |
Multiply PC expansions given by double* argument p1 with scalar a and return the result in p1. | |
void | MultiplyInPlace (Array1D< double > &p1, const double &a) const |
Multiply PC expansions given by Array1D argument p1 with scalar a and return the result in p1. | |
void | Subtract (const double *p1, const double *p2, double *p3) const |
Subtract PC expansion p2 from p1, and return the result in p3, with all arguments given as double*. | |
void | Subtract (const Array1D< double > &p1, const Array1D< double > &p2, Array1D< double > &p3) const |
Subtract PC expansion p2 from p1, and return the result in p3, with all arguments given as Array1D structures. | |
void | SubtractInPlace (double *p1, const double *p2) const |
Subtract PC expansion p2 from p1, and return the result in p1, with all arguments given as double*. | |
void | SubtractInPlace (Array1D< double > &p1, const Array1D< double > &p2) const |
Subtract PC expansion p2 from p1, and return the result in p1, with all arguments given as Array1D structures. | |
void | Prod (const double *p1, const double *p2, double *p3) const |
Multiply two PC expansions given by double* arguments p1 and p2, and return the result in p3. | |
void | Prod (const Array1D< double > &p1, const Array1D< double > &p2, Array1D< double > &p3) const |
Multipy two PC expansions given by Array1D arguments p1 and p2, and return the result in p3. | |
void | Prod3 (const double *p1, const double *p2, const double *p3, double *p4) const |
Multiply three PC expansions given by double* arguments p1, p2, and p3, and return the result in p4. | |
void | Prod3 (const Array1D< double > &p1, const Array1D< double > &p2, const Array1D< double > &p3, Array1D< double > &p4) const |
Multipy three PC expansions given by Array1D arguments p1, p2, and p3, and return the result in p4. | |
void | Polyn (const double *polycf, int npoly, const double *p1, double *p2) const |
Evaluates a polynomial of PC that is given in double* argument p1. Polynomial coefficients are given in double* argument polycf of size npoly. The output PC is contained in double* argument p2. | |
void | Polyn (const Array1D< double > &polycf, const Array1D< double > &p1, Array1D< double > &p2) const |
Evaluates a polynomial of PC that is given by Array1D argument p1. Polynomial coefficients are given in the Array1D argument polycf. The output PC is contained in Array1D argument p2. | |
void | PolynMulti (const Array1D< double > &polycf, const Array2D< int > &mindex, const Array2D< double > &p1, Array1D< double > &p2) const |
Evaluates a multivariate polynomial of a set of PC inputs given by Array2D argument p1 (each column of p1 is a PC input). Polynomial coefficients are given in Array1D argument polycf. Multiindex set for the multivariate polynomial is given in Array2D argument mindex. The output PC is contained in Array1D argument p2. | |
void | Exp (const double *p1, double *p2) const |
Take the exp() of the PC expansion given by double* argument p1, and return the result in p2. | |
void | Exp (const Array1D< double > &p1, Array1D< double > &p2) const |
Take the exp() of the PC expansion given by Array1D argument p1, and return the result in p2. | |
void | Log (const double *p1, double *p2) const |
Take the natural logarithm log() of the PC expansion given by double* argument p1, and return the result in p2. The logarithm is evaluated either via Taylor series or via integration depending on the value of parameter logMethod_. | |
void | Log (const Array1D< double > &p1, Array1D< double > &p2) const |
Take the natural logarithm, log(), of the PC expansion given by Array1D argument p1, and return the result in Array1D argument p2. | |
void | Log10 (const double *p1, double *p2) const |
Take the logarithm to base 10 of the PC expansion given by double* argument p1, and return the result in p2. | |
void | Log10 (const Array1D< double > &p1, Array1D< double > &p2) const |
Take the logarithm to base 10 of the PC expansion given by Array1D argument p1, and return the result in Array1D argument p2. | |
void | RPow (const double *p1, double *p2, const double &a) const |
Evaluate power a (a real number) of PC expansion given by double* argument p1, and return the result in p2. The power is computed as p1^a = exp(a*log(p1)), where log(p1) is evaluated either via Taylor series or via integration depending on the value of parameter logMethod_. | |
void | RPow (const Array1D< double > &p1, Array1D< double > &p2, const double &a) const |
Evaluate power a (a real number) of PC expansion given by Array1D argument p1, and return the result in Array1D argument p2. | |
void | IPow (const double *p1, double *p2, const int &ia) const |
Evaluate power ia (an integer number) of PC expansion given by double* argument p1, and return the result in p2. | |
void | IPow (const Array1D< double > &p1, Array1D< double > &p2, const int &ia) const |
Evaluate power ia (an integer number) of PC expansion given by Array1D argument p1, and return the result in Array1D argument p2. | |
void | Inv (const double *p1, double *p2) const |
Evaluate the inverse of PC expansion given by double* argument p1, and return the result in p2. The inverse is computed using the division function. | |
void | Inv (const Array1D< double > &p1, Array1D< double > &p2) const |
Evaluate the inverse of PC expansion given by Array1D argument p1, and return the result in Array1D argument p2. | |
void | Div (const double *p1, const double *p2, double *p3) const |
Divide the PC expansion p1 by p2, and return the result in p3 (All arguments in double* format) | |
void | Div (const Array1D< double > &p1, const Array1D< double > &p2, Array1D< double > &p3) const |
Divide the PC expansion p1 by p2, and return the result in p3 (All arguments in Array1D<double> format) | |
double | StDv (const double *p) const |
Returns the standard deviation of PC expansion p in a double* format. | |
double | StDv (const Array1D< double > &p) const |
Returns the standard deviation of PC expansion p (Argument in Array1D<double> format) | |
double | GetModesRMS (const double *p) const |
Compute the rms average of the PC coefficients (i.e. the square root of the average of the square of the PC coefficients, not taking into account any basis functions). (Arguments in double* format) | |
double | GetModesRMS (const Array1D< double > &p) const |
Compute the rms average of the PC coefficients (i.e. the square root of the average of the square of the PC coefficients, not taking into account any basis functions). (Arguments in Array1D<double> format) | |
void | Derivative (const double *p1, double *p2) const |
Computes derivatives of univariate PC given by coefficients p1 returns coefficient vector of the derivative in p2. | |
void | Derivative (const Array1D< double > &p1, Array1D< double > &p2) const |
Computes derivatives of univariate PC given by coefficients p1 returns coefficient vector of the derivative in p2. | |
int | GetNumTripleProd () const |
Returns number of triple products. | |
void | GetTripleProd (int *nTriple, int *iProd, int *jProd, double *Cijk) const |
Returns triple products indices (int*/double* version) | |
void | GetTripleProd (Array1D< int > &nTriple, Array1D< int > &iProd, Array1D< int > &jProd, Array1D< double > &Cijk) const |
Returns triple products indices (Array version) | |
int | GetNumQuadProd () const |
Returns number of quad products. | |
void | GetQuadProd (int *nQuad, int *iProd, int *jProd, int *kProd, double *Cijkl) const |
Returns quad products indices (int*/double* version) | |
void | GetQuadProd (Array1D< int > &nQuad, Array1D< int > &iProd, Array1D< int > &jProd, Array1D< int > &kProd, Array1D< double > &Cijkl) const |
Returns quad products indices (Array version) | |
void | SeedBasisRandNumGen (const int &seed) const |
Random sample generator functions. | |
void | DrawSampleSet (const Array1D< double > &p, Array1D< double > &samples) |
Draw a set of samples from the PC expansion p, and return the result in the array samples. All arguments are in Array1D<double> format The number of samples requested is assumed to be the size of the samples array. | |
void | DrawSampleSet (const double *p, double *samples, const int &nSamples) |
Draw a set of samples from the PC expansion given in double* argument p, and return the result in double* array samples. The number of samples requested is the argument nSamples. | |
void | DrawSampleVar (Array2D< double > &samples) const |
Draw a set of samples of the underlying germ random variable. | |
void | DrawSampleVar (double *samples, const int &nS, const int &nD) const |
double | EvalPC (const Array1D< double > &p, Array1D< double > &randVarSamples) |
PC evaluation functionalities. | |
double | EvalPC (const double *p, const double *randVarSamples) |
Evaluate the given PC expansion p, at the specified values of the random variables, randVarSamples. All arguments in const double* format. | |
void | EvalPCAtCustPoints (Array1D< double > &xch, Array2D< double > &custPoints, Array1D< double > &p) |
Evaluate the given PC expansion at given set of points with given coefficient vector and return the values in an 1D Array in the first argument. | |
void | EvalBasisAtCustPts (const Array2D< double > &custPoints, Array2D< double > &psi) |
Evaluate Basis Functions at given points custPoints and return in the array psi. | |
void | EvalBasisAtCustPts (const double *custPoints, const int npts, double *psi) |
void | GalerkProjection (const Array1D< double > &fcn, Array1D< double > &ck) |
Galerkin projection functionalities. | |
void | GalerkProjectionMC (const Array2D< double > &x, const Array1D< double > &fcn, Array1D< double > &ck) |
Galerkin Projection via Monte-Carlo integration. | |
int | ComputeOrders (Array1D< int > &orders) |
Multiindex parsing functionalities. | |
int | ComputeEffDims (int *effdim) |
Computes the effective dimensionality of each basis term, i.e., the number of dimensions that enter with a non-zero degree. also returns the maximal dimensionality among all basis terms. | |
int | ComputeEffDims (Array1D< int > &effdim) |
Computes the effective dimensionality of each basis term, i.e., the number of dimensions that enter with a non-zero degree. also returns the maximal dimensionality among all basis terms. | |
void | EncodeMindex (Array1D< Array2D< int > > &sp_mindex) |
Encode multiIndex into a 'sparse' format where the bases are ordered by their effective dimensionality. The i-th element in sp_mindex stores all the bases that have effective dimensionality equal to i. Also, only non-zero components are stored. | |
double | ComputeMean (const double *coef) |
Moment/sensitivity extraction given coefficients. | |
double | ComputeMean (Array1D< double > &coef) |
Compute the mean of the PC given coefficient array coef(seeking the zero-th order multiindex) | |
double | ComputeVarFrac (const double *coef, double *varfrac) |
Compute the variance fractions of each basis term given coefficients in double *coef; returns the variance fractions in the double *varfrac. | |
double | ComputeVarFrac (Array1D< double > &coef, Array1D< double > &varfrac) |
Compute the variance fractions of each basis term given coefficient array coef; returns the variance fractions in the array varfrac. | |
void | ComputeMainSens (Array1D< double > &coef, Array1D< double > &mainsens) |
Compute main effect sensitivity (Sobol) indices given coefficient array coef; returns the indices in the array mainsens. | |
void | ComputeTotSens (Array1D< double > &coef, Array1D< double > &totsens) |
Compute total effect sensitivity (Sobol) indices given coefficient array coeff; returns the indices in the array totsens. | |
void | ComputeJointSens (Array1D< double > &coef, Array2D< double > &jointsens) |
Compute joint effect sensitivity (Sobol) indices given coefficient array coeff; returns the indices in the array jointsens. | |
void | SetVerbosity (int verbosity) |
Other. | |
void | EvalNormSq (Array1D< double > &normsq) |
Evaluate norms-squared of all bases and return in the array normsq. | |
void | EvalNormSq (double *normsq, const int npc) |
void | EvalNormSqExact (Array1D< double > &normsq) |
Evaluate norms-squared analytically of all bases and return in the array normsq. | |
bool | IsInDomain (double x) |
Check if the point x is in the PC domain. | |
Private Types | |
typedef std::map< int, PCSet * > | OMap_t |
Definition of a map to connect integer indexes with pointers to this class. | |
Private Member Functions | |
PCSet () | |
Dummy default constructor, which should not be used as it is not well defined Therefore we make it private so it is not accessible. | |
PCSet (const PCSet &obj) | |
Dummy copy constructor, which should not be used as it is currently not well defined. Therefore we make it private so it is not accessible. | |
void | ComputeMaxOrdPerDim () |
Compute maximal order per dimension and fill in the array maxOrdPerDim_. | |
void | Initialize (const string ordertype) |
Initialization of the appropriate variables. | |
void | InitISP () |
Initialize quadrature for computing triple products(ISP) and orthogonal projection(NISP) | |
void | InitNISP () |
Initialize variables that are needed only in non-intrusive computations. | |
void | EvalBasisProd3 () |
Evaluate the expectation of product of three basis functions. | |
void | EvalBasisProd4 () |
Evaluate the expectation of product of four basis functions. | |
void | GMRESMatrixVectorProd (const double *x, const double *a, double *y) const |
Actual C++ implementation of the matric vector multiplication for GMRES for the division operation. | |
void | LogTaylor (const double *p1, double *p2) const |
Computes natural logarithm using Taylor expansion: N p2 = ln(p1) = ln(p1Mean) + sum d n=1 n. | |
void | LogInt (const double *p1, double *p2) const |
Computes natural logarithm by numerical integration: calculate p2=ln(p1) by integrating du=dx/x to get ln(x) | |
int | LogIntRhs (sunrealtype t, N_Vector y, N_Vector ydot, void *f_data) const |
Evaluates rhs necessary to compute natural logarithm via integration. | |
int | Check_CVflag (void *flagvalue, const char *funcname, int opt) const |
Check cvode return for errors. | |
Static Private Member Functions | |
static void | GMRESMatrixVectorProdWrapper (int *n, double *x, double *y, int *nelt, int *ia, int *ja, double *a, int *obj) |
Wrapper for Matrix-vector multiplication routine to be called by GMRES. | |
static void | GMRESPreCondWrapper (int *n, double *r, double *z, int *nelt, int *ia, int *ja, double *a, int *obj, double *rwork, int *iwork) |
Wrapper for preconditioner routine to be called by GMRES. | |
static int | LogIntRhsWrapper (sunrealtype t, N_Vector y, N_Vector ydot, void *f_data) |
Wrapper for LogIntRhs. The first component of f_data pointer carries an integer handle identifying the appropriate PC object. | |
Private Attributes | |
int | uqtkverbose_ |
Verbosity level. | |
string | spType_ |
String indicator of ISP or NISP implementation type. | |
string | pcType_ |
String indicator of PC type. | |
string | pcSeq_ |
String indicator of multiindex ordering. | |
PCBasis * | p_basis_ |
Pointer to the class that defines the basis type and functions. | |
int | order_ |
Order of the PC representation. | |
int | maxorddim_ |
Maximal order within all dimensions. | |
Array1D< int > | maxOrders_ |
Array of maximum orders requested if custom(HDMR) ordering is requested. | |
Array1D< int > | maxOrdPerDim_ |
Array of maximum orders per dimension. | |
const int | nDim_ |
Number of stochastic dimensions (degrees of freedom) in the PC representation. | |
int | nQuadPoints_ |
Number of quadrature points used. | |
int | nPCTerms_ |
Total number of terms in the PC expansions. | |
double | rTolTaylor_ |
Relative tolerance for Taylor series approximations. | |
int | maxTermTaylor_ |
Max number of terms in Taylor series approximations. | |
double | SMALL_ |
Tolerance to avoid floating-point errors. | |
double | rTolGMRESDiv_ |
GMRES tolerance in Div() | |
Array2D< double > | psi_ |
Array to store basis functions evaluated at quadrature points for each order: psi_(iqp,ipc) contains the value of the polynomial chaos ipc-th basis at the location of quadrature point iqp. | |
Array1D< double > | psiSq_ |
Array with the norms squared of the basis functions, corresponding to each term in the PC expansion. | |
Array2D< double > | quadPoints_ |
Array to store quadrature points. | |
Array1D< double > | quadWeights_ |
Array to store quadrature weights. | |
Array2D< int > | quadIndices_ |
Array to store quadrature point indexing; useful for nested rules. | |
Array2D< int > | multiIndex_ |
Array to store multi-index: multiIndex_(ipc,idim) contains the order of the basis function associated with dimension idim, for the ipc-th term in the PC expansion. | |
Array1D< Array1D< int > > | iProd2_ |
i-indices of <\Psi_i \Psi_j \Psi_k> terms that are not zero, for all k | |
Array1D< Array1D< int > > | jProd2_ |
j-indices of <\Psi_i \Psi_j \Psi_k> terms that are not zero, for all k | |
Array1D< Array1D< double > > | psiIJKProd2_ |
<\Psi_i \Psi_j \Psi_k> terms that are not zero, for all k | |
Array1D< Array1D< int > > | iProd3_ |
i-indices of <\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l | |
Array1D< Array1D< int > > | jProd3_ |
j-indices of <\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l | |
Array1D< Array1D< int > > | kProd3_ |
k-indices of <\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l | |
Array1D< Array1D< double > > | psiIJKLProd3_ |
<\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l | |
LogCompMethod | logMethod_ |
Flag for method to compute log: TaylorSeries or Integration. | |
int | CVmaxord_ |
CVODE parameter: maximal order. | |
int | CVmaxnumsteps_ |
CVODE parameter: maximal number of steps. | |
double | CVinitstep_ |
CVODE parameter: initial step size. | |
double | CVmaxstep_ |
CVODE parameter: maximal step size. | |
double | CVrelt_ |
CVODE parameter: relative tolerance. | |
double | CVabst_ |
CVODE parameter: absolute tolerance. | |
int | my_index_ |
Index of this class. | |
int | narg_ |
Number of free parameters to specify the basis. | |
double | alpha_ |
Parameter alpha for PCs that require a parameter (LG,SW,JB) | |
double | beta_ |
Parameter beta for PCs that require two parameters (SW,JB) | |
Static Private Attributes | |
static int | next_index_ = 0 |
index of next object in map | |
static OMap_t * | omap_ = NULL |
Map to connect integer indexes with pointers to this class. | |
Defines and initializes PC basis function set and provides functions to manipulate PC expansions defined on this basis set.
|
private |
Definition of a map to connect integer indexes with pointers to this class.
PCSet::PCSet | ( | const string | sp_type, |
const int | order, | ||
const int | n_dim, | ||
const string | pc_type, | ||
const double | alpha = 0.0, | ||
const double | betta = 1.0 ) |
Constructor: initializes the PC basis set for the order, number of dimensions and type that are passed in.
Implementation type sp_type has three options "ISP" (intrusive methods), "NISP" (non-intrusive), or "NISPnoq" (non-intrusive without quadrature initialization)
PCSet::PCSet | ( | const string | sp_type, |
const int | order, | ||
const int | n_dim, | ||
const string | pc_type, | ||
const string | pc_seq, | ||
const double | alpha = 0.0, | ||
const double | betta = 1.0 ) |
Constructor: initializes the PC basis set for the order, number of dimensions and type that are passed in. It also customizes the multiindex sequence ( lexicographical-lex, colexicographical-colex, reverse lexicographical-revlex, and reverse clexicographical-revcolex).
Implementation type sp_type has three options "ISP" (intrusive methods), "NISP" (non-intrusive), or "NISPnoq" (non-intrusive without quadrature initialization)
PCSet::PCSet | ( | const string | sp_type, |
const Array1D< int > & | maxOrders, | ||
const int | n_dim, | ||
const string | pc_type, | ||
const double | alpha = 0.0, | ||
const double | betta = 1.0 ) |
Constructor: initializes the PC basis set ordered in an HDMR fashion given order per each HDMR rank (univariate, bivariate, etc...)
Implementation type sp_type has three options "ISP" (intrusive methods), "NISP" (non-intrusive), or "NISPnoq" (non-intrusive without quadrature initialization)
PCSet::PCSet | ( | const string | sp_type, |
const Array2D< int > & | customMultiIndex, | ||
const string | pc_type, | ||
const double | alpha = 0.0, | ||
const double | betta = 1.0 ) |
Constructor: initializes the PC basis set for a given custom multiIndex.
Implementation type sp_type has three options "ISP" (intrusive methods), "NISP" (non-intrusive), or "NISPnoq" (non-intrusive without quadrature initialization)
PCSet::~PCSet | ( | ) |
Destructor: cleans up all memory and destroys object.
|
inlineprivate |
Dummy default constructor, which should not be used as it is not well defined Therefore we make it private so it is not accessible.
|
inlineprivate |
Dummy copy constructor, which should not be used as it is currently not well defined. Therefore we make it private so it is not accessible.
void PCSet::Add | ( | const Array1D< double > & | p1, |
const Array1D< double > & | p2, | ||
Array1D< double > & | p3 ) const |
Add two PC expansions given by Array1D arguments p1 and p2, and return the result in p3.
void PCSet::Add | ( | const double * | p1, |
const double * | p2, | ||
double * | p3 ) const |
Add two PC expansions given by double* arguments p1 and p2, and return the result in p3.
Add PC expansions given by Array1D argument p2 to p1 and return the result in p1.
void PCSet::AddInPlace | ( | double * | p1, |
const double * | p2 ) const |
Add PC expansions given by double* argument p2 to p1 and return the result in p1.
|
private |
Check cvode return for errors.
int PCSet::ComputeEffDims | ( | Array1D< int > & | effdim | ) |
Computes the effective dimensionality of each basis term, i.e., the number of dimensions that enter with a non-zero degree. also returns the maximal dimensionality among all basis terms.
int PCSet::ComputeEffDims | ( | int * | effdim | ) |
Computes the effective dimensionality of each basis term, i.e., the number of dimensions that enter with a non-zero degree. also returns the maximal dimensionality among all basis terms.
Compute joint effect sensitivity (Sobol) indices given coefficient array coeff; returns the indices in the array jointsens.
Compute main effect sensitivity (Sobol) indices given coefficient array coef; returns the indices in the array mainsens.
|
private |
Compute maximal order per dimension and fill in the array maxOrdPerDim_.
double PCSet::ComputeMean | ( | Array1D< double > & | coef | ) |
Compute the mean of the PC given coefficient array coef(seeking the zero-th order multiindex)
double PCSet::ComputeMean | ( | const double * | coef | ) |
Moment/sensitivity extraction given coefficients.
Compute the mean of the PC given coefficients in double *coef (seeking the zero-th order multiindex)
int PCSet::ComputeOrders | ( | Array1D< int > & | orders | ) |
Multiindex parsing functionalities.
Computes the order of each basis term and return it in the array orders, also returns the maximal order
Compute total effect sensitivity (Sobol) indices given coefficient array coeff; returns the indices in the array totsens.
Compute the variance fractions of each basis term given coefficient array coef; returns the variance fractions in the array varfrac.
double PCSet::ComputeVarFrac | ( | const double * | coef, |
double * | varfrac ) |
Compute the variance fractions of each basis term given coefficients in double *coef; returns the variance fractions in the double *varfrac.
Copy PC expansion p2 into p1 (i.e. p1 = p2).
All arguments in Array format
void PCSet::Copy | ( | double * | p1, |
const double * | p2 ) const |
Copy PC expansion p2 into p1 (i.e. p1 = p2).
All arguments in double* format.
void PCSet::ddPhi | ( | Array1D< double > & | x, |
Array2D< int > & | mindex, | ||
Array2D< double > & | grad, | ||
Array1D< double > & | ck ) |
Evaluate Gradient at a single d-dim point.
for a PCSet object
Evaluate Hessian at a single d-dim point and d-dim basis polynomial.
Computes derivatives of univariate PC given by coefficients p1 returns coefficient vector of the derivative in p2.
Supports LU and HG bases only
Supports only for 1d PCs
void PCSet::Derivative | ( | const double * | p1, |
double * | p2 ) const |
Computes derivatives of univariate PC given by coefficients p1 returns coefficient vector of the derivative in p2.
Supports LU and HG bases only
Supports only for 1d PCs
void PCSet::Div | ( | const Array1D< double > & | p1, |
const Array1D< double > & | p2, | ||
Array1D< double > & | p3 ) const |
Divide the PC expansion p1 by p2, and return the result in p3 (All arguments in Array1D<double> format)
void PCSet::Div | ( | const double * | p1, |
const double * | p2, | ||
double * | p3 ) const |
Divide the PC expansion p1 by p2, and return the result in p3 (All arguments in double* format)
The "division" p3 = p1/p2 is performed by solving the system of equations p2*p3 = p1 for the unknown p3.
void PCSet::dPhi | ( | Array1D< double > & | x, |
Array2D< int > & | mindex, | ||
Array1D< double > & | grad, | ||
Array1D< double > & | ck ) |
Evaluate Gradient at a single d-dim point.
for a PCSet object
void PCSet::dPhi | ( | Array2D< double > & | x, |
Array2D< int > & | mindex, | ||
Array2D< double > & | grad, | ||
Array1D< double > & | ck ) |
Evaluate Gradient at a multiple d-dim x points.
for a PCSet object
Set Gradient and Hessian operators.
Evaluate Gradient at a single d-dim point and d-dim basis polynomial
Draw a set of samples from the PC expansion p, and return the result in the array samples. All arguments are in Array1D<double> format The number of samples requested is assumed to be the size of the samples array.
void PCSet::DrawSampleSet | ( | const double * | p, |
double * | samples, | ||
const int & | nSamples ) |
Draw a set of samples from the PC expansion given in double* argument p, and return the result in double* array samples. The number of samples requested is the argument nSamples.
void PCSet::DrawSampleVar | ( | Array2D< double > & | samples | ) | const |
Draw a set of samples of the underlying germ random variable.
void PCSet::DrawSampleVar | ( | double * | samples, |
const int & | nS, | ||
const int & | nD ) const |
Encode multiIndex into a 'sparse' format where the bases are ordered by their effective dimensionality. The i-th element in sp_mindex stores all the bases that have effective dimensionality equal to i. Also, only non-zero components are stored.
Evaluate Basis Functions at given points custPoints and return in the array psi.
void PCSet::EvalBasisAtCustPts | ( | const double * | custPoints, |
const int | npts, | ||
double * | psi ) |
|
private |
Evaluate the expectation of product of three basis functions.
|
private |
Evaluate the expectation of product of four basis functions.
void PCSet::EvalNormSq | ( | Array1D< double > & | normsq | ) |
Evaluate norms-squared of all bases and return in the array normsq.
void PCSet::EvalNormSq | ( | double * | normsq, |
const int | npc ) |
void PCSet::EvalNormSqExact | ( | Array1D< double > & | normsq | ) |
Evaluate norms-squared analytically of all bases and return in the array normsq.
PC evaluation functionalities.
Evaluate the given PC expansion p, at the specified values of the random variables, randVarSamples. All arguments in const Array1D<double> format
double PCSet::EvalPC | ( | const double * | p, |
const double * | randVarSamples ) |
Evaluate the given PC expansion p, at the specified values of the random variables, randVarSamples. All arguments in const double* format.
void PCSet::EvalPCAtCustPoints | ( | Array1D< double > & | xch, |
Array2D< double > & | custPoints, | ||
Array1D< double > & | p ) |
Evaluate the given PC expansion at given set of points with given coefficient vector and return the values in an 1D Array in the first argument.
Take the exp() of the PC expansion given by Array1D argument p1, and return the result in p2.
void PCSet::Exp | ( | const double * | p1, |
double * | p2 ) const |
Take the exp() of the PC expansion given by double* argument p1, and return the result in p2.
Relies on Taylor series expansion: exp(x) = 1 + x + x^2/2! + x^3/3! + ... However, for efficiency and to avoid overflow, the terms are computed as d_i = d_{i-1}*x/i. Also, to reduce the number of terms needed in the series, we subtract the mean out of a random variable u as u = u_0 + (u-u_0) and exp(u) = exp(u_0)*exp(u-u_0), where exp(u_0) can be computed with the regular exp(double& ) function
Galerkin projection functionalities.
Performs (NISP) Galerkin projection, given function evaluations at quadrature points Returns in the coefficient vector in the second argument
Overload this with forward function pointers
There is no double* version of this function
void PCSet::GalerkProjectionMC | ( | const Array2D< double > & | x, |
const Array1D< double > & | fcn, | ||
Array1D< double > & | ck ) |
Galerkin Projection via Monte-Carlo integration.
Overload this with forward function pointers
There is no double* version of this function
|
inline |
Get the value of the parameter alpha.
|
inline |
Get the value of the parameter beta.
|
inline |
Get relative tolerance for GMRES in Div routine.
double PCSet::GetModesRMS | ( | const Array1D< double > & | p | ) | const |
Compute the rms average of the PC coefficients (i.e. the square root of the average of the square of the PC coefficients, not taking into account any basis functions). (Arguments in Array1D<double> format)
double PCSet::GetModesRMS | ( | const double * | p | ) | const |
Compute the rms average of the PC coefficients (i.e. the square root of the average of the square of the PC coefficients, not taking into account any basis functions). (Arguments in double* format)
|
inline |
Get the multiindex (return Array2D)
void PCSet::GetMultiIndex | ( | int * | mindex | ) | const |
Get the multiindex (return double *)
|
inline |
Get the PC dimensionality.
|
inline |
Get the norm-squared.
|
inline |
Get the number of quadrature points.
|
inline |
Get the number of terms in a PC expansion of this order and dimension.
int PCSet::GetNumQuadProd | ( | ) | const |
Returns number of quad products.
int PCSet::GetNumTripleProd | ( | ) | const |
Returns number of triple products.
|
inline |
Get the PC order.
|
inline |
Get and set variables/arrays inline.
Get the PC type
|
inline |
Get the values of the basis polynomials evaluated at the quadrature points.
|
inline |
Get the polynomials evaluated at the quadrature points folded into a one-dimensional array psi.
|
inline |
Get the basis polynomial norms-squared in an array class object psisq.
|
inline |
Get the basis polynomial norms-squared in a double* array psisq.
|
inline |
Get the quadrature points.
|
inline |
Get the quadrature points folded into a one-dimensional array quad.
|
inline |
Get the quadrature points and weights.
void PCSet::GetQuadProd | ( | Array1D< int > & | nQuad, |
Array1D< int > & | iProd, | ||
Array1D< int > & | jProd, | ||
Array1D< int > & | kProd, | ||
Array1D< double > & | Cijkl ) const |
Returns quad products indices (Array version)
void PCSet::GetQuadProd | ( | int * | nQuad, |
int * | iProd, | ||
int * | jProd, | ||
int * | kProd, | ||
double * | Cijkl ) const |
Returns quad products indices (int*/double* version)
|
inline |
Get the quadrature weights.
|
inline |
Get the quadrature weights folded into a one-dimensional array wghts.
|
inline |
Get maximum number of terms in Taylor series approximations.
|
inline |
Get relative tolerance for Taylor series approximations.
void PCSet::GetTripleProd | ( | Array1D< int > & | nTriple, |
Array1D< int > & | iProd, | ||
Array1D< int > & | jProd, | ||
Array1D< double > & | Cijk ) const |
Returns triple products indices (Array version)
void PCSet::GetTripleProd | ( | int * | nTriple, |
int * | iProd, | ||
int * | jProd, | ||
double * | Cijk ) const |
Returns triple products indices (int*/double* version)
|
private |
Actual C++ implementation of the matric vector multiplication for GMRES for the division operation.
Given the structure of the problem, this boils down to the product between two PC variables.
|
inlinestaticprivate |
Wrapper for Matrix-vector multiplication routine to be called by GMRES.
As GMRES is a Fortran77 routine, this routine is defined as a static function. One of the function arguments (obj) was originally isym, a flag for matrix symmetry, but has been repurposed to carry an integer handle to identify this object.
|
inlinestaticprivate |
Wrapper for preconditioner routine to be called by GMRES.
As GMRES is a Fortran77 routine, this routine is defined as a static function. One of the function arguments (obj) was originally isym, a flag for matrix symmetry, but has been repurposed to carry an integer handle to identify this object.
|
private |
Initialization of the appropriate variables.
|
private |
Initialize quadrature for computing triple products(ISP) and orthogonal projection(NISP)
Initialize variables that are needed only in intrusive computations
void PCSet::InitMeanStDv | ( | const double & | m, |
const double & | s, | ||
Array1D< double > & | p ) const |
Initializes a PC expansion p in Array1D<double> format to have the same distribution as the underlying PC germ, but with a specified mean m and standard deviation s.
void PCSet::InitMeanStDv | ( | const double & | m, |
const double & | s, | ||
double * | p ) const |
Intrusive arithmetics.
Initializes a PC expansion p in a double* format to have the same distribution as the underlying PC germ, but with a specified mean m and standard deviation s
|
private |
Initialize variables that are needed only in non-intrusive computations.
void PCSet::Inv | ( | const double * | p1, |
double * | p2 ) const |
Evaluate the inverse of PC expansion given by double* argument p1, and return the result in p2. The inverse is computed using the division function.
void PCSet::IPow | ( | const double * | p1, |
double * | p2, | ||
const int & | ia ) const |
Evaluate power ia (an integer number) of PC expansion given by double* argument p1, and return the result in p2.
bool PCSet::IsInDomain | ( | double | x | ) |
Check if the point x is in the PC domain.
void PCSet::Log | ( | const double * | p1, |
double * | p2 ) const |
Take the natural logarithm log() of the PC expansion given by double* argument p1, and return the result in p2. The logarithm is evaluated either via Taylor series or via integration depending on the value of parameter logMethod_.
void PCSet::Log10 | ( | const double * | p1, |
double * | p2 ) const |
Take the logarithm to base 10 of the PC expansion given by double* argument p1, and return the result in p2.
First use Log() to compute the natural logarithm and then divide it by log(10)
|
private |
Computes natural logarithm by numerical integration: calculate p2=ln(p1) by integrating du=dx/x to get ln(x)
|
private |
Evaluates rhs necessary to compute natural logarithm via integration.
|
inlinestaticprivate |
Wrapper for LogIntRhs. The first component of f_data pointer carries an integer handle identifying the appropriate PC object.
|
private |
Computes natural logarithm using Taylor expansion: N p2 = ln(p1) = ln(p1Mean) + sum d n=1 n.
(n+1) (-1) n p1 where d = -— *x , and x = ---— - 1 n n p1Mean
void PCSet::Multiply | ( | const Array1D< double > & | p1, |
const double & | a, | ||
Array1D< double > & | p2 ) const |
Multiply PC expansion p1 with scalar a and return the result in p2. All PCEs are in Array1D format.
void PCSet::Multiply | ( | const double * | p1, |
const double & | a, | ||
double * | p2 ) const |
Multiply PC expansion p1 with scalar a and return the result in p2. All PCEs are in double* format.
void PCSet::MultiplyInPlace | ( | Array1D< double > & | p1, |
const double & | a ) const |
Multiply PC expansions given by Array1D argument p1 with scalar a and return the result in p1.
void PCSet::MultiplyInPlace | ( | double * | p1, |
const double & | a ) const |
Multiply PC expansions given by double* argument p1 with scalar a and return the result in p1.
void PCSet::Polyn | ( | const double * | polycf, |
int | npoly, | ||
const double * | p1, | ||
double * | p2 ) const |
Evaluates a polynomial of PC that is given in double* argument p1. Polynomial coefficients are given in double* argument polycf of size npoly. The output PC is contained in double* argument p2.
void PCSet::PolynMulti | ( | const Array1D< double > & | polycf, |
const Array2D< int > & | mindex, | ||
const Array2D< double > & | p1, | ||
Array1D< double > & | p2 ) const |
Evaluates a multivariate polynomial of a set of PC inputs given by Array2D argument p1 (each column of p1 is a PC input). Polynomial coefficients are given in Array1D argument polycf. Multiindex set for the multivariate polynomial is given in Array2D argument mindex. The output PC is contained in Array1D argument p2.
void PCSet::PrintMultiIndex | ( | ) | const |
Print information on the screen.
Print the multi-indices for all terms on the screen
void PCSet::PrintMultiIndexNormSquared | ( | ) | const |
For all terms, print their multi-index and norm^2 on the screen.
void PCSet::Prod | ( | const Array1D< double > & | p1, |
const Array1D< double > & | p2, | ||
Array1D< double > & | p3 ) const |
Multipy two PC expansions given by Array1D arguments p1 and p2, and return the result in p3.
void PCSet::Prod | ( | const double * | p1, |
const double * | p2, | ||
double * | p3 ) const |
Multiply two PC expansions given by double* arguments p1 and p2, and return the result in p3.
void PCSet::Prod3 | ( | const Array1D< double > & | p1, |
const Array1D< double > & | p2, | ||
const Array1D< double > & | p3, | ||
Array1D< double > & | p4 ) const |
Multipy three PC expansions given by Array1D arguments p1, p2, and p3, and return the result in p4.
void PCSet::Prod3 | ( | const double * | p1, |
const double * | p2, | ||
const double * | p3, | ||
double * | p4 ) const |
Multiply three PC expansions given by double* arguments p1, p2, and p3, and return the result in p4.
void PCSet::RPow | ( | const double * | p1, |
double * | p2, | ||
const double & | a ) const |
Evaluate power a (a real number) of PC expansion given by double* argument p1, and return the result in p2. The power is computed as p1^a = exp(a*log(p1)), where log(p1) is evaluated either via Taylor series or via integration depending on the value of parameter logMethod_.
void PCSet::SeedBasisRandNumGen | ( | const int & | seed | ) | const |
Random sample generator functions.
Reseed the random number generator used for the sampling of the PC variables and expansions
|
inline |
Set the relative tolerance for GMRES in Div routine.
|
inline |
Set method of computing the log function.
Use the argument TaylorSeries to select the Taylor series approach or Integration to select the integration method.
Set the quadrature rule.
Obtain 1d quadrature points and weights
void PCSet::SetQuadRule | ( | const string | grid_type, |
const string | fs_type, | ||
int | param ) |
Set the quadrature points by specifying a grid type, a full/sparse indicator, and an integer parameter.
Full/sparse switch fs_type can be either 'full' or 'sparse' The parameter param is the number of points per dimension for full quadrature, and the level for sparse quadrature Options for grid_type are, besides the standard PC types, 'CC' (Clenshaw-Curtis), 'CCO' (Clenshaw-Curtis open), 'NC' (Newton-Cotes), 'NCO' (Newton-Cotes open), where open means that endpoints are expluded
void PCSet::SetQuadRule | ( | Quad & | quadRule | ) |
Set a custom quadrature rule by pointing to the corresponding object.
|
inline |
Set maximum number of terms in Taylor series approximations.
|
inline |
Set relative tolerance for Taylor series approximations.
|
inline |
Other.
Set the verbosity level
double PCSet::StDv | ( | const Array1D< double > & | p | ) | const |
Returns the standard deviation of PC expansion p (Argument in Array1D<double> format)
double PCSet::StDv | ( | const double * | p | ) | const |
Returns the standard deviation of PC expansion p in a double* format.
void PCSet::Subtract | ( | const Array1D< double > & | p1, |
const Array1D< double > & | p2, | ||
Array1D< double > & | p3 ) const |
Subtract PC expansion p2 from p1, and return the result in p3, with all arguments given as Array1D structures.
void PCSet::Subtract | ( | const double * | p1, |
const double * | p2, | ||
double * | p3 ) const |
Subtract PC expansion p2 from p1, and return the result in p3, with all arguments given as double*.
Subtract PC expansion p2 from p1, and return the result in p1, with all arguments given as Array1D structures.
void PCSet::SubtractInPlace | ( | double * | p1, |
const double * | p2 ) const |
Subtract PC expansion p2 from p1, and return the result in p1, with all arguments given as double*.
|
private |
Parameter alpha for PCs that require a parameter (LG,SW,JB)
|
private |
Parameter beta for PCs that require two parameters (SW,JB)
|
private |
CVODE parameter: absolute tolerance.
|
private |
CVODE parameter: initial step size.
|
private |
CVODE parameter: maximal number of steps.
|
private |
CVODE parameter: maximal order.
|
private |
CVODE parameter: maximal step size.
|
private |
CVODE parameter: relative tolerance.
i-indices of <\Psi_i \Psi_j \Psi_k> terms that are not zero, for all k
i-indices of <\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l
j-indices of <\Psi_i \Psi_j \Psi_k> terms that are not zero, for all k
j-indices of <\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l
k-indices of <\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l
|
private |
Flag for method to compute log: TaylorSeries or Integration.
|
private |
Maximal order within all dimensions.
|
private |
Array of maximum orders requested if custom(HDMR) ordering is requested.
|
private |
Array of maximum orders per dimension.
|
private |
Max number of terms in Taylor series approximations.
|
private |
Array to store multi-index: multiIndex_(ipc,idim) contains the order of the basis function associated with dimension idim, for the ipc-th term in the PC expansion.
|
private |
Index of this class.
|
private |
Number of free parameters to specify the basis.
|
private |
Number of stochastic dimensions (degrees of freedom) in the PC representation.
|
staticprivate |
index of next object in map
|
private |
Total number of terms in the PC expansions.
|
private |
Number of quadrature points used.
|
staticprivate |
Map to connect integer indexes with pointers to this class.
|
private |
Order of the PC representation.
|
private |
Pointer to the class that defines the basis type and functions.
|
private |
String indicator of multiindex ordering.
|
private |
String indicator of PC type.
|
private |
Array to store basis functions evaluated at quadrature points for each order: psi_(iqp,ipc) contains the value of the polynomial chaos ipc-th basis at the location of quadrature point iqp.
<\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l
<\Psi_i \Psi_j \Psi_k> terms that are not zero, for all k
|
private |
Array with the norms squared of the basis functions, corresponding to each term in the PC expansion.
|
private |
Array to store quadrature point indexing; useful for nested rules.
|
private |
Array to store quadrature points.
|
private |
Array to store quadrature weights.
|
private |
GMRES tolerance in Div()
|
private |
Relative tolerance for Taylor series approximations.
|
private |
Tolerance to avoid floating-point errors.
|
private |
String indicator of ISP or NISP implementation type.
|
private |
Verbosity level.