UQTk: Uncertainty Quantification Toolkit 3.1.5
PCSet.h
Go to the documentation of this file.
1/* =====================================================================================
2
3 The UQ Toolkit (UQTk) version 3.1.5
4 Copyright (2024) NTESS
5 https://www.sandia.gov/UQToolkit/
6 https://github.com/sandialabs/UQTk
7
8 Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
9 Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government
10 retains certain rights in this software.
11
12 This file is part of The UQ Toolkit (UQTk)
13
14 UQTk is open source software: you can redistribute it and/or modify
15 it under the terms of BSD 3-Clause License
16
17 UQTk is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 BSD 3 Clause License for more details.
21
22 You should have received a copy of the BSD 3 Clause License
23 along with UQTk. If not, see https://choosealicense.com/licenses/bsd-3-clause/.
24
25 Questions? Contact the UQTk Developers at https://github.com/sandialabs/UQTk/discussions
26 Sandia National Laboratories, Livermore, CA, USA
27===================================================================================== */
31
32#ifndef PCSET_H_SEEN
33#define PCSET_H_SEEN
34
35#include <iostream>
36#include <sstream>
37#include <string.h>
38#include <stdio.h>
39#include <map>
40#include "Array1D.h"
41#include "Array2D.h"
42#include "error_handlers.h"
43#include "ftndefs.h"
44#include "quad.h"
45
46/* CVODE headers */
47#include <cvode/cvode.h> /* prototypes for CVODE fcts., consts. */
48// #include <cvode/cvode_direct.h> /* access to CVDls interface */
49#include <nvector/nvector_serial.h> /* serial N_Vector types, fcts., macros */
50#include <sunmatrix/sunmatrix_dense.h> /* access to dense SUNMatrix */
51#include <sunlinsol/sunlinsol_dense.h> /* access to dense SUNLinearSolver */
52// #include <cvode/cvode_dense.h> /* prototype for CVDense */
53#include <sundials/sundials_types.h> /* definition of type sunrealtype */
54#include <sundials/sundials_context.h> /* for SUNContext_Create */
55#include <sundials/sundials_dense.h> /* definitions DlsMat DENSE_ELEM */
56
57
58#include <iostream>
59#include <string.h>
60#include <stdio.h>
61#include <sstream>
62using namespace std; // needed for python string conversion
63
64class PCBasis;
65class Quad;
66
68
72
73class PCSet {
74public:
75
82 PCSet(const string sp_type, const int order, const int n_dim, const string pc_type,
83 const double alpha=0.0, const double betta=1.0);
84
85
95 PCSet(const string sp_type, const int order, const int n_dim, const string pc_type, const string pc_seq,
96 const double alpha=0.0, const double betta=1.0);
97
98
105 PCSet(const string sp_type, const Array1D<int>& maxOrders, const int n_dim, const string pc_type,
106 const double alpha=0.0, const double betta=1.0);
107
115 PCSet(const string sp_type, const Array2D<int>& customMultiIndex, const string pc_type,
116 const double alpha=0.0, const double betta=1.0);
117
119 ~PCSet();
120
124
134
141
145
148 void SetQd1d(Array1D<double>& qdpts1d,Array1D<double>& wghts1d, int nqd);
149
161 void SetQuadRule(const string grid_type,const string fs_type,int param);
162
164 void SetQuadRule(Quad &quadRule);
165
169
171 void PrintMultiIndex() const;
172
174 void PrintMultiIndexNormSquared() const;
175
176
180
182 string GetPCType() const {return pcType_;}
183
185 double GetAlpha() const {return alpha_;}
186
188 double GetBeta() const {return beta_;}
189
191 void GetMultiIndex(Array2D<int> &mindex) const {mindex=multiIndex_;}
192
194 void GetMultiIndex(int *mindex) const;
195
198 void GetNormSq(Array1D<double>& normsq) const {normsq=psiSq_;}
199
201 int GetNumberPCTerms() const {return nPCTerms_;}
202
204 int GetNDim() const {return nDim_;}
205
207 int GetOrder() const {return order_;}
208
210 int GetNQuadPoints() const {return nQuadPoints_;}
211
213 void GetQuadPoints(Array2D<double>& quad) const {quad=quadPoints_;}
214
217
219 void GetQuadPoints(double* quad) const {for(int i=0;i<nQuadPoints_;i++) for(int j=0;j<nDim_;j++) quad[i*nDim_+j]=quadPoints_(i,j);}
220
222 void GetQuadWeights(Array1D<double>& wghts) const {wghts=quadWeights_;}
223
225 void GetQuadWeights(double* wghts) const {for(int i=0;i<nQuadPoints_;i++) wghts[i]=quadWeights_(i);}
226
229 void GetPsi(Array2D<double>& psi) const {psi=psi_;}
230
233 void GetPsi(double* psi) const {for(int i=0;i<nQuadPoints_;i++) for(int j=0;j<nPCTerms_;j++) psi[i*nPCTerms_+j]=psi_(i,j);}
234
236 void GetPsiSq(Array1D<double>& psisq) const {psisq=psiSq_;}
237
239 void GetPsiSq(double* psisq) const {for(int i=0;i<nPCTerms_;i++) psisq[i]=psiSq_(i);}
240
242 double GetTaylorTolerance() const {return rTolTaylor_;}
243
245 void SetTaylorTolerance(const double& rTol) {rTolTaylor_ = rTol;}
246
248 int GetTaylorTermsMax() const {return maxTermTaylor_;}
249
251 void SetTaylorTermsMax(const int& maxTerm) {maxTermTaylor_ = maxTerm;}
252
257 void SetLogCompMethod(const LogCompMethod& logMethod) {logMethod_ = logMethod;}
258
260 double GetGMRESDivTolerance() const {return rTolGMRESDiv_;}
261
263 void SetGMRESDivTolerance(const double& rTol) {rTolGMRESDiv_ = rTol;}
264
265
269
276 void InitMeanStDv(const double& m, const double& s, double* p) const;
277
284 void InitMeanStDv(const double& m, const double& s, Array1D<double>& p) const;
285
289 void Copy(double* p1, const double* p2) const;
290
295 void Copy(Array1D<double>& p1, const Array1D<double>& p2) const;
296
299 void Add(const double* p1, const double* p2, double* p3) const;
300
304 void Add(const Array1D<double>& p1, const Array1D<double>& p2, Array1D<double>& p3) const;
305
308 void AddInPlace(double* p1, const double* p2) const;
309
313 void AddInPlace(Array1D<double>& p1, const Array1D<double>& p2) const;
314
317 void Multiply(const double* p1, const double& a, double* p2) const;
318
322 void Multiply(const Array1D<double>& p1, const double& a, Array1D<double>& p2) const;
323
326 void MultiplyInPlace(double* p1, const double& a) const;
327
331 void MultiplyInPlace(Array1D<double>& p1, const double& a) const;
332
335 void Subtract(const double* p1, const double* p2, double* p3) const;
336
340 void Subtract(const Array1D<double>& p1, const Array1D<double>& p2, Array1D<double>& p3) const;
341
344 void SubtractInPlace(double* p1, const double* p2) const;
345
349 void SubtractInPlace(Array1D<double>& p1, const Array1D<double>& p2) const;
350
353 void Prod(const double* p1, const double* p2, double* p3) const;
354
358 void Prod(const Array1D<double>& p1, const Array1D<double>& p2, Array1D<double>& p3) const;
359
362 void Prod3(const double* p1, const double* p2, const double* p3, double* p4) const;
363
367 void Prod3(const Array1D<double>& p1, const Array1D<double>& p2, const Array1D<double>& p3,
368 Array1D<double>& p4) const;
369
374 void Polyn(const double* polycf, int npoly, const double* p1, double* p2) const;
375
380 void Polyn(const Array1D<double>& polycf, const Array1D<double>& p1, Array1D<double>& p2) const;
381
392 void PolynMulti(const Array1D<double>& polycf, const Array2D<int>& mindex, const Array2D<double>& p1, Array1D<double>& p2) const;
393
409 void Exp(const double* p1, double* p2) const;
410
414 void Exp(const Array1D<double>& p1, Array1D<double>& p2) const;
415
420 void Log(const double* p1, double* p2) const;
421
425 void Log(const Array1D<double>& p1, Array1D<double>& p2) const;
426
431 void Log10(const double* p1, double* p2) const;
432
436 void Log10(const Array1D<double>& p1, Array1D<double>& p2) const;
437
443 void RPow(const double* p1, double* p2, const double& a) const;
444
448 void RPow(const Array1D<double>& p1, Array1D<double>& p2, const double& a) const;
449
452 void IPow(const double* p1, double* p2, const int& ia) const;
453
457 void IPow(const Array1D<double>& p1, Array1D<double>& p2, const int& ia) const;
458
462 void Inv(const double* p1, double* p2) const;
463
467 void Inv(const Array1D<double>& p1, Array1D<double>& p2) const;
468
481 void Div(const double* p1, const double* p2, double* p3) const;
482
486 void Div(const Array1D<double>& p1, const Array1D<double>& p2, Array1D<double>& p3) const;
487
491 double StDv(const double* p) const;
492
498 double StDv(const Array1D<double>& p) const;
499
503 double GetModesRMS(const double* p) const;
504
509 double GetModesRMS(const Array1D<double>& p) const;
510
516 void Derivative(const double* p1, double* p2) const;
517
523 void Derivative(const Array1D<double>& p1, Array1D<double>& p2) const;
524
526 int GetNumTripleProd() const;
528 void GetTripleProd(int *nTriple, int *iProd, int *jProd, double *Cijk) const;
530 void GetTripleProd(Array1D<int>& nTriple, Array1D<int>& iProd, Array1D<int>& jProd, Array1D<double>& Cijk) const;
532 int GetNumQuadProd() const;
534 void GetQuadProd(int *nQuad, int *iProd, int *jProd, int *kProd, double *Cijkl) const;
536 void GetQuadProd(Array1D<int> &nQuad, Array1D<int> &iProd, Array1D<int> &jProd, Array1D<int> &kProd,
537 Array1D<double> &Cijkl) const;
538
542
545 void SeedBasisRandNumGen(const int& seed) const;
546
552 void DrawSampleSet(const Array1D<double>& p, Array1D<double>& samples);
553
557 void DrawSampleSet(const double* p, double* samples, const int& nSamples);
558
561 void DrawSampleVar(Array2D<double>& samples) const;
562 void DrawSampleVar(double *samples, const int &nS, const int &nD) const;
563
567
575 double EvalPC(const Array1D<double>& p, Array1D<double>& randVarSamples);
576
584 double EvalPC(const double* p, const double* randVarSamples);
585
590
593 void EvalBasisAtCustPts(const Array2D<double>& custPoints,Array2D<double>& psi);
594
595 void EvalBasisAtCustPts(const double* custPoints, const int npts, double* psi);
596 // void EvalBasisAtCustPts(const int npts, const int ndim, const int npc, const double *custPoints, double *psi);
597
601
609
616
620
624 int ComputeOrders(Array1D<int>& orders);
625
631 int ComputeEffDims(int *effdim);
632
638 int ComputeEffDims(Array1D<int> &effdim);
639
643 void EncodeMindex(Array1D< Array2D<int> >& sp_mindex);
644
648
651 double ComputeMean(const double *coef);
652
654 double ComputeMean(Array1D<double>& coef);
655
660 double ComputeVarFrac(const double *coef, double *varfrac);
661
666 double ComputeVarFrac(Array1D<double>& coef, Array1D<double>& varfrac);
667
670 void ComputeMainSens(Array1D<double>& coef, Array1D<double>& mainsens);
671
674 void ComputeTotSens(Array1D<double>& coef, Array1D<double>& totsens);
675
679 void ComputeJointSens(Array1D<double>& coef, Array2D<double>& jointsens);
680
681
685
688 void SetVerbosity(int verbosity) { uqtkverbose_ = verbosity; }
689
692 void EvalNormSq(Array1D<double>& normsq);
693 void EvalNormSq(double* normsq, const int npc);
694
698 void EvalNormSqExact(Array1D<double>& normsq);
699
701 bool IsInDomain(double x);
702
703
704
705 private:
709 PCSet(): order_(0), nDim_(0) {};
710
711
717 PCSet(const PCSet &obj):order_(obj.order_), nDim_(obj.nDim_) {};
718
720 void ComputeMaxOrdPerDim();
721
725 void Initialize(const string ordertype);
726
728 // void InitQuadrature();
729
731 void InitISP();
733 void InitNISP();
734
736 void EvalBasisProd3();
737
739 void EvalBasisProd4();
740
749 static void GMRESMatrixVectorProdWrapper(int* n, double* x, double* y, int* nelt,
750 int* ia, int* ja, double* a, int* obj) {
751 // Look up *obj in the map that relates integer indices to pointers to PCSet
752 OMap_t::iterator it = omap_->find(*obj);
753 if(it == omap_->end()) {
754 string err_message = (string) "GMRESMatrixVectorProdWrapper():"
755 + " the callback object is not a valid entry in the map";
756 throw Tantrum(err_message);
757 }
758 // Perform callback to the member function of the proper PCSet instance
759 it->second->GMRESMatrixVectorProd(x, a, y);
760
761 return;
762 }
763
772 static void GMRESPreCondWrapper(int* n, double* r, double* z, int* nelt,
773 int* ia, int* ja, double* a, int* obj,
774 double* rwork, int* iwork) { };
775
781 void GMRESMatrixVectorProd(const double* x, const double*a, double* y) const;
782
795 void LogTaylor(const double* p1, double* p2) const;
796
799 void LogInt(const double* p1, double* p2) const;
800
805 static int LogIntRhsWrapper(sunrealtype t, N_Vector y, N_Vector ydot, void *f_data)
806 {
807 double indxobj = ((double*) f_data)[0] ;
808
809 OMap_t::iterator it = omap_->find((int) indxobj);
810
811 if (it == omap_->end())
812 {
813 string err_message = (string) "LogIntRhsWrapper():"
814 + " the callback object is not a valid entry in the map";
815 throw Tantrum(err_message);
816 }
817
818 // Perform callback to the member function of the proper PCSet instance
819 it->second->LogIntRhs(t,y,ydot,f_data);
820
821 return ( 0 ) ;
822
823 }
824
826 int LogIntRhs(sunrealtype t, N_Vector y, N_Vector ydot, void *f_data) const;
827
831
833 string spType_;
834
836 string pcType_;
837
839 string pcSeq_;
840
843
846
849
852
855
857 const int nDim_;
858
861
864
867
870
872 double SMALL_;
873
876
881
885
888
891
894
899
903
907
911
915
919
923
927
930
933
936
939
942
944 double CVrelt_;
945
947 double CVabst_ ;
948
950 int Check_CVflag(void *flagvalue, const char *funcname, int opt) const;
951
954
956 int narg_;
957
959 double alpha_;
961 double beta_;
962
964 typedef std::map<int, PCSet*> OMap_t;
966 static int next_index_;
968 static OMap_t *omap_;
969
970};
971
972#endif /* !PCSET_H_SEEN */
1D Array class for any type T
2D Array class for any type T
LogCompMethod
Definition PCSet.h:67
@ TaylorSeries
Definition PCSet.h:67
@ Integration
Definition PCSet.h:67
Stores data of any type T in a 1D array.
Definition Array1D.h:61
Stores data of any type T in a 2D array.
Definition Array2D.h:60
Contains all basis type specific definitions and operations needed to generate a PCSet.
Definition PCBasis.h:47
Defines and initializes PC basis function set and provides functions to manipulate PC expansions defi...
Definition PCSet.h:73
Array2D< double > quadPoints_
Array to store quadrature points.
Definition PCSet.h:887
Array1D< int > maxOrders_
Array of maximum orders requested if custom(HDMR) ordering is requested.
Definition PCSet.h:851
void GetPsi(Array2D< double > &psi) const
Get the values of the basis polynomials evaluated at the quadrature points.
Definition PCSet.h:229
int nQuadPoints_
Number of quadrature points used.
Definition PCSet.h:860
void GalerkProjection(const Array1D< double > &fcn, Array1D< double > &ck)
Galerkin projection functionalities.
Definition PCSet.cpp:2584
void EvalNormSq(Array1D< double > &normsq)
Evaluate norms-squared of all bases and return in the array normsq.
Definition PCSet.cpp:2962
Array2D< double > psi_
Array to store basis functions evaluated at quadrature points for each order: psi_(iqp,...
Definition PCSet.h:880
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.
Definition PCSet.cpp:1083
Array1D< Array1D< double > > psiIJKProd2_
<\Psi_i \Psi_j \Psi_k> terms that are not zero, for all k
Definition PCSet.h:910
void SetGMRESDivTolerance(const double &rTol)
Set the relative tolerance for GMRES in Div routine.
Definition PCSet.h:263
double rTolGMRESDiv_
GMRES tolerance in Div()
Definition PCSet.h:875
string GetPCType() const
Get and set variables/arrays inline.
Definition PCSet.h:182
void GetQuadWeights(Array1D< double > &wghts) const
Get the quadrature weights.
Definition PCSet.h:222
void AddInPlace(double *p1, const double *p2) const
Add PC expansions given by double* argument p2 to p1 and return the result in p1.
Definition PCSet.cpp:947
void GetNormSq(Array1D< double > &normsq) const
Get the norm-squared.
Definition PCSet.h:198
double GetGMRESDivTolerance() const
Get relative tolerance for GMRES in Div routine.
Definition PCSet.h:260
bool IsInDomain(double x)
Check if the point x is in the PC domain.
Definition PCSet.cpp:3019
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 ...
Definition PCSet.cpp:1172
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 v...
Definition PCSet.cpp:2453
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.
Definition PCSet.cpp:1127
void SeedBasisRandNumGen(const int &seed) const
Random sample generator functions.
Definition PCSet.cpp:2319
void GalerkProjectionMC(const Array2D< double > &x, const Array1D< double > &fcn, Array1D< double > &ck)
Galerkin Projection via Monte-Carlo integration.
Definition PCSet.cpp:2635
void GetPsiSq(double *psisq) const
Get the basis polynomial norms-squared in a double* array psisq.
Definition PCSet.h:239
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 o...
Definition PCSet.cpp:1210
void EvalNormSqExact(Array1D< double > &normsq)
Evaluate norms-squared analytically of all bases and return in the array normsq.
Definition PCSet.cpp:2999
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,...
Definition PCSet.cpp:1547
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 ...
Definition PCSet.cpp:1910
PCSet()
Dummy default constructor, which should not be used as it is not well defined Therefore we make it pr...
Definition PCSet.h:709
double SMALL_
Tolerance to avoid floating-point errors.
Definition PCSet.h:872
double rTolTaylor_
Relative tolerance for Taylor series approximations.
Definition PCSet.h:866
double GetBeta() const
Get the value of the parameter beta.
Definition PCSet.h:188
double ComputeVarFrac(const double *coef, double *varfrac)
Compute the variance fractions of each basis term given coefficients in double *coef; returns the var...
Definition PCSet.cpp:2832
std::map< int, PCSet * > OMap_t
Definition of a map to connect integer indexes with pointers to this class.
Definition PCSet.h:964
void EvalBasisProd3()
Evaluate the expectation of product of three basis functions.
Definition PCSet.cpp:450
void GetMultiIndex(Array2D< int > &mindex) const
Get the multiindex (return Array2D)
Definition PCSet.h:191
int narg_
Number of free parameters to specify the basis.
Definition PCSet.h:956
double CVinitstep_
CVODE parameter: initial step size.
Definition PCSet.h:938
int Check_CVflag(void *flagvalue, const char *funcname, int opt) const
Check cvode return for errors.
Definition PCSet.cpp:2287
void SetQd1d(Array1D< double > &qdpts1d, Array1D< double > &wghts1d, int nqd)
Set the quadrature rule.
Definition PCSet.cpp:725
void Log(const double *p1, double *p2) const
Take the natural logarithm log() of the PC expansion given by double* argument p1,...
Definition PCSet.cpp:1427
void ComputeTotSens(Array1D< double > &coef, Array1D< double > &totsens)
Compute total effect sensitivity (Sobol) indices given coefficient array coeff; returns the indices i...
Definition PCSet.cpp:2911
Array1D< Array1D< int > > iProd2_
i-indices of <\Psi_i \Psi_j \Psi_k> terms that are not zero, for all k
Definition PCSet.h:902
Array1D< Array1D< int > > jProd3_
j-indices of <\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l
Definition PCSet.h:918
void GetQuadProd(int *nQuad, int *iProd, int *jProd, int *kProd, double *Cijkl) const
Returns quad products indices (int*‍/double* version)
Definition PCSet.cpp:686
void GetQuadWeights(double *wghts) const
Get the quadrature weights folded into a one-dimensional array wghts.
Definition PCSet.h:225
void GetPsi(double *psi) const
Get the polynomials evaluated at the quadrature points folded into a one-dimensional array psi.
Definition PCSet.h:233
void Derivative(const double *p1, double *p2) const
Computes derivatives of univariate PC given by coefficients p1 returns coefficient vector of the deri...
Definition PCSet.cpp:2202
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*.
Definition PCSet.cpp:1057
static OMap_t * omap_
Map to connect integer indexes with pointers to this class.
Definition PCSet.h:968
Array1D< Array1D< int > > jProd2_
j-indices of <\Psi_i \Psi_j \Psi_k> terms that are not zero, for all k
Definition PCSet.h:906
Array1D< Array1D< int > > iProd3_
i-indices of <\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l
Definition PCSet.h:914
void InitNISP()
Initialize variables that are needed only in non-intrusive computations.
Definition PCSet.cpp:420
void EvalBasisProd4()
Evaluate the expectation of product of four basis functions.
Definition PCSet.cpp:580
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*.
Definition PCSet.cpp:1027
int order_
Order of the PC representation.
Definition PCSet.h:845
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)
Definition PCSet.cpp:1695
int GetNQuadPoints() const
Get the number of quadrature points.
Definition PCSet.h:210
void PrintMultiIndexNormSquared() const
For all terms, print their multi-index and norm^2 on the screen.
Definition PCSet.cpp:805
double beta_
Parameter beta for PCs that require two parameters (SW,JB)
Definition PCSet.h:961
Array1D< int > maxOrdPerDim_
Array of maximum orders per dimension.
Definition PCSet.h:854
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.
Definition PCSet.cpp:1299
int ComputeEffDims(int *effdim)
Computes the effective dimensionality of each basis term, i.e., the number of dimensions that enter w...
Definition PCSet.cpp:2711
Array1D< double > psiSq_
Array with the norms squared of the basis functions, corresponding to each term in the PC expansion.
Definition PCSet.h:884
void SetVerbosity(int verbosity)
Other.
Definition PCSet.h:688
void PrintMultiIndex() const
Print information on the screen.
Definition PCSet.cpp:778
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...
Definition PCSet.cpp:1468
Array2D< int > quadIndices_
Array to store quadrature point indexing; useful for nested rules.
Definition PCSet.h:893
double CVmaxstep_
CVODE parameter: maximal step size.
Definition PCSet.h:941
int GetOrder() const
Get the PC order.
Definition PCSet.h:207
double EvalPC(const Array1D< double > &p, Array1D< double > &randVarSamples)
PC evaluation functionalities.
Definition PCSet.cpp:2409
void GetPsiSq(Array1D< double > &psisq) const
Get the basis polynomial norms-squared in an array class object psisq.
Definition PCSet.h:236
void Initialize(const string ordertype)
Initialization of the appropriate variables.
Definition PCSet.cpp:165
int nPCTerms_
Total number of terms in the PC expansions.
Definition PCSet.h:863
string pcType_
String indicator of PC type.
Definition PCSet.h:836
int GetNumTripleProd() const
Returns number of triple products.
Definition PCSet.cpp:536
void ComputeMaxOrdPerDim()
Compute maximal order per dimension and fill in the array maxOrdPerDim_.
Definition PCSet.cpp:151
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.
Definition PCSet.cpp:1002
double GetTaylorTolerance() const
Get relative tolerance for Taylor series approximations.
Definition PCSet.h:242
void EvalBasisAtCustPts(const Array2D< double > &custPoints, Array2D< double > &psi)
Evaluate Basis Functions at given points custPoints and return in the array psi.
Definition PCSet.cpp:2491
void dPhi(Array1D< double > &x, Array2D< int > &mindex, Array1D< double > &grad, Array1D< double > &ck)
Evaluate Gradient at a single d-dim point.
Definition PCSet.cpp:266
void ComputeJointSens(Array1D< double > &coef, Array2D< double > &jointsens)
Compute joint effect sensitivity (Sobol) indices given coefficient array coeff; returns the indices i...
Definition PCSet.cpp:2934
void GetTripleProd(int *nTriple, int *iProd, int *jProd, double *Cijk) const
Returns triple products indices (int*‍/double* version)
Definition PCSet.cpp:544
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 paramete...
Definition PCSet.cpp:742
int ComputeOrders(Array1D< int > &orders)
Multiindex parsing functionalities.
Definition PCSet.cpp:2689
double ComputeMean(const double *coef)
Moment/sensitivity extraction given coefficients.
Definition PCSet.cpp:2794
void LogInt(const double *p1, double *p2) const
Computes natural logarithm by numerical integration: calculate p2=ln(p1) by integrating du=dx/x to ge...
Definition PCSet.cpp:2044
Array1D< Array1D< int > > kProd3_
k-indices of <\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l
Definition PCSet.h:922
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....
Definition PCSet.cpp:1646
int uqtkverbose_
Verbosity level.
Definition PCSet.h:830
int my_index_
Index of this class.
Definition PCSet.h:953
PCSet(const PCSet &obj)
Dummy copy constructor, which should not be used as it is currently not well defined....
Definition PCSet.h:717
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.
Definition PCSet.cpp:1687
void GetQuadPointsWeights(Array2D< double > &quad, Array1D< double > &wghts) const
Get the quadrature points and weights.
Definition PCSet.h:216
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.
Definition PCSet.cpp:319
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.
Definition PCSet.cpp:917
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 th...
Definition PCSet.h:805
double StDv(const double *p) const
Returns the standard deviation of PC expansion p in a double* format.
Definition PCSet.cpp:1873
int CVmaxnumsteps_
CVODE parameter: maximal number of steps.
Definition PCSet.h:935
PCBasis * p_basis_
Pointer to the class that defines the basis type and functions.
Definition PCSet.h:842
void Copy(double *p1, const double *p2) const
Copy PC expansion p2 into p1 (i.e. p1 = p2).
Definition PCSet.cpp:888
Array1D< double > quadWeights_
Array to store quadrature weights.
Definition PCSet.h:890
int maxTermTaylor_
Max number of terms in Taylor series approximations.
Definition PCSet.h:869
void ComputeMainSens(Array1D< double > &coef, Array1D< double > &mainsens)
Compute main effect sensitivity (Sobol) indices given coefficient array coef; returns the indices in ...
Definition PCSet.cpp:2882
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....
Definition PCSet.cpp:2327
~PCSet()
Destructor: cleans up all memory and destroys object.
Definition PCSet.cpp:127
int GetTaylorTermsMax() const
Get maximum number of terms in Taylor series approximations.
Definition PCSet.h:248
void dPhi_alpha(Array1D< double > &x, Array1D< int > &alpha, Array1D< double > &grad)
Set Gradient and Hessian operators.
Definition PCSet.cpp:244
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 ...
Definition PCSet.cpp:1505
double GetAlpha() const
Get the value of the parameter alpha.
Definition PCSet.h:185
string pcSeq_
String indicator of multiindex ordering.
Definition PCSet.h:839
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.
Definition PCSet.cpp:973
Array1D< Array1D< double > > psiIJKLProd3_
<\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l
Definition PCSet.h:926
LogCompMethod logMethod_
Flag for method to compute log: TaylorSeries or Integration.
Definition PCSet.h:929
void EncodeMindex(Array1D< Array2D< int > > &sp_mindex)
Encode multiIndex into a 'sparse' format where the bases are ordered by their effective dimensionalit...
Definition PCSet.cpp:2745
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.
Definition PCSet.cpp:1936
const int nDim_
Number of stochastic dimensions (degrees of freedom) in the PC representation.
Definition PCSet.h:857
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.
Definition PCSet.h:772
double CVrelt_
CVODE parameter: relative tolerance.
Definition PCSet.h:944
void SetLogCompMethod(const LogCompMethod &logMethod)
Set method of computing the log function.
Definition PCSet.h:257
void DrawSampleVar(Array2D< double > &samples) const
Draw a set of samples of the underlying germ random variable.
Definition PCSet.cpp:2360
int LogIntRhs(sunrealtype t, N_Vector y, N_Vector ydot, void *f_data) const
Evaluates rhs necessary to compute natural logarithm via integration.
Definition PCSet.cpp:2176
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.
Definition PCSet.h:749
void SetTaylorTolerance(const double &rTol)
Set relative tolerance for Taylor series approximations.
Definition PCSet.h:245
double alpha_
Parameter alpha for PCs that require a parameter (LG,SW,JB)
Definition PCSet.h:959
double CVabst_
CVODE parameter: absolute tolerance.
Definition PCSet.h:947
void ddPhi(Array1D< double > &x, Array2D< int > &mindex, Array2D< double > &grad, Array1D< double > &ck)
Evaluate Gradient at a single d-dim point.
Definition PCSet.cpp:358
int CVmaxord_
CVODE parameter: maximal order.
Definition PCSet.h:932
void SetTaylorTermsMax(const int &maxTerm)
Set maximum number of terms in Taylor series approximations.
Definition PCSet.h:251
string spType_
String indicator of ISP or NISP implementation type.
Definition PCSet.h:833
int GetNumberPCTerms() const
Get the number of terms in a PC expansion of this order and dimension.
Definition PCSet.h:201
static int next_index_
index of next object in map
Definition PCSet.h:966
void GetQuadPoints(double *quad) const
Get the quadrature points folded into a one-dimensional array quad.
Definition PCSet.h:219
int GetNDim() const
Get the PC dimensionality.
Definition PCSet.h:204
int maxorddim_
Maximal order within all dimensions.
Definition PCSet.h:848
void InitMeanStDv(const double &m, const double &s, double *p) const
Intrusive arithmetics.
Definition PCSet.cpp:833
void InitISP()
Initialize quadrature for computing triple products(ISP) and orthogonal projection(NISP)
Definition PCSet.cpp:394
Array2D< int > multiIndex_
Array to store multi-index: multiIndex_(ipc,idim) contains the order of the basis function associated...
Definition PCSet.h:898
void GetQuadPoints(Array2D< double > &quad) const
Get the quadrature points.
Definition PCSet.h:213
int GetNumQuadProd() const
Returns number of quad products.
Definition PCSet.cpp:677
Generates quadrature rules.
Definition quad.h:54
Header file for the quadrature class.