MUQ  0.4.3
muq::Approximation::BasisExpansion Class Reference

Class for defining expansions of basis functions defined by a MultiIndexSet and collection of IndexScalarBasis functions. More...

#include <BasisExpansion.h>

Inheritance diagram for muq::Approximation::BasisExpansion:

Detailed Description

Class for defining expansions of basis functions defined by a MultiIndexSet and collection of IndexScalarBasis functions.

Consider an expansion of the form

\[f_j(x) = \sum_{\alpha\in A} c_{j,\alpha} \Phi_\alpha(x), \]

where \(x\in \mathbb{R}^N\), \(c_{j,\alpha} \in \mathbb{R}\), is a coefficient, \(\alpha\) is a multindex in the set of indices \(A\), and \(\Phi_\alpha(x)\) is a multivariate basis function defined by the multiindex, which takes the form

\[ \Phi_\alpha(x) = \prod_{i=1}^N \phi_{i}(x_i,\alpha_i). \]

The univariate functions \(\phi_{i}(x_i,\alpha_i)\) can be polynomials, Hermite functions, or some ther IndexScalarBasis. For example, we could use Hermite polynomials for \(i=0\) and Legendre polynomials for \(i=1\), so that \(\phi_0(x_0,\alpha_0)\) would be a Hermite polynomial of order \(\alpha_0\) and \(\phi_1(x_1,\alpha_1)\) would be Legendre polynomial of order \(\alpha_1\).

Evaluating this WorkPiece should be done through the muq::Modeling::WorkGraph interface, (WorkPiece::Evaluate, WorkPiece::Jacobian, etc...). The input arguments is either the vector \(x\) or both the vector \(x\) and a MatrixXd of coefficients defining \(c_{j,\alpha}\) in the expansion. If the coefficients are not passed, the most recently set coefficients are used. For example, output1 and output2 will be the same below:

auto expansion = std::make_shared<BasisExpansion>();
Eigen::VectorXd x;
Eigen::MatrixXd c;
// Fill in x and c ...
boost::any output1 = expansion->Evaluate(x,c)[0];
Eigen::MatrixXd outputVec1 = boost::any_cast<Eigen::MatrixXd>(output1);
boost::any output2 = expansion->Evaluate(x)[0];
Eigen::MatrixXd outputVec2 = boost::any_cast<Eigen::MatrixXd>(output1);

@seealso muq::Utilities::MultiIndexSet, muq::Utilities::IndexScalarBasis, muq::Modeling::WorkPiece

Definition at line 64 of file BasisExpansion.h.

Public Member Functions

 BasisExpansion (std::vector< std::shared_ptr< IndexedScalarBasis >> const &basisCompsIn, bool coeffInput=false)
 
 BasisExpansion (std::vector< std::shared_ptr< IndexedScalarBasis >> const &basisCompsIn, std::shared_ptr< muq::Utilities::MultiIndexSet > multisIn, bool coeffInput=false)
 
 BasisExpansion (std::vector< std::shared_ptr< IndexedScalarBasis >> const &basisCompsIn, std::shared_ptr< muq::Utilities::MultiIndexSet > multisIn, Eigen::MatrixXd const &coeffsIn, bool coeffInput=false)
 
virtual ~BasisExpansion ()=default
 
virtual unsigned NumTerms () const
 
Eigen::MatrixXd BuildVandermonde (Eigen::MatrixXd const &evalPts) const
 
Eigen::MatrixXd BuildDerivMatrix (Eigen::MatrixXd const &evalPts, int wrtDim) const
 
Eigen::MatrixXd SecondDerivative (unsigned outputDim, unsigned wrtDim1, unsigned wrtDim2, Eigen::VectorXd const &evalPt, Eigen::MatrixXd const &coeffs)
 
Eigen::MatrixXd SecondDerivative (unsigned outputDim, unsigned wrtDim1, unsigned wrtDim2, Eigen::VectorXd const &evalPt)
 
Eigen::MatrixXd GetCoeffs () const
 
void SetCoeffs (Eigen::MatrixXd const &allCoeffs)
 
const std::shared_ptr< muq::Utilities::MultiIndexSetMultis () const
 
virtual void ToHDF5 (std::string filename, std::string groupName="/") const
 Saves the expansion to group in an HDF5 file. More...
 
virtual void ToHDF5 (muq::Utilities::H5Object &group) const
 Saves the expansion to a group in an HDF5 file. More...
 
- Public Member Functions inherited from muq::Modeling::ModPiece
 ModPiece (std::vector< int > const &inputSizes, std::vector< int > const &outputSizes)
 
 ModPiece (Eigen::VectorXi const &inputSizes, Eigen::VectorXi const &outputSizes)
 
virtual ~ModPiece ()=default
 
virtual double GetRunTime (const std::string &method="Evaluate") const override
 Get the average run time for one of the implemented methods. More...
 
virtual void ResetCallTime () override
 Resets the number of call and times. More...
 
virtual unsigned long int GetNumCalls (const std::string &method="Evaluate") const override
 get the number of times one of the implemented methods has been called. More...
 
virtual std::vector< Eigen::VectorXd > const & Evaluate (std::vector< Eigen::VectorXd > const &input)
 Evaluate the ModPiece. More...
 
virtual std::vector< Eigen::VectorXd > const & Evaluate (ref_vector< Eigen::VectorXd > const &input)
 
 VARIADIC_TO_REFVECTOR (Evaluate, Eigen::VectorXd, std::vector< Eigen::VectorXd > const &)
 
virtual Eigen::VectorXd const & Gradient (unsigned int const outputDimWrt, unsigned int const inputDimWrt, std::vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sensitivity)
 Compute the Gradient \(J^Tv\). More...
 
virtual Eigen::VectorXd const & Gradient (unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sensitivity)
 
Eigen::VectorXd const & Gradient (unsigned int outWrt, unsigned int inWrt, Eigen::VectorXd const &last, Eigen::VectorXd const &sens)
 
template<typename... Args>
Eigen::VectorXd const & Gradient (unsigned int wrtOut, unsigned int wrtIn, Args const &... args)
 
Eigen::VectorXd const & ApplyHessian (unsigned int outWrt, unsigned int inWrt1, unsigned int inWrt2, Eigen::VectorXd const &last, Eigen::VectorXd const &sens, Eigen::VectorXd const &vec)
 
template<typename... Args>
Eigen::VectorXd const & ApplyHessian (unsigned int wrtOut, unsigned int wrtIn1, unsigned int wrtIn2, Args const &... args)
 
virtual Eigen::MatrixXd const & Jacobian (unsigned int const outputDimWrt, unsigned int const inputDimWrt, std::vector< Eigen::VectorXd > const &input)
 Compute the Jacobian of this ModPiece. More...
 
virtual Eigen::MatrixXd const & Jacobian (unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input)
 
template<typename... Args>
Eigen::MatrixXd const & Jacobian (unsigned int outWrt, unsigned int inWrt, Args const &... args)
 
template<typename... Args>
Eigen::MatrixXd JacobianByFD (unsigned int outWrt, unsigned int inWrt, Args const &... args)
 
template<typename... Args>
Eigen::MatrixXd ApplyJacobianByFD (unsigned int outWrt, unsigned int inWrt, Args const &... args)
 
virtual Eigen::VectorXd const & ApplyJacobian (unsigned int const outputDimWrt, unsigned int const inputDimWrt, std::vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &vec)
 Apply the Jacobian of this ModPiece to a vector. More...
 
virtual Eigen::VectorXd const & ApplyJacobian (unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &vec)
 
Eigen::VectorXd const & ApplyJacobian (unsigned int outWrt, unsigned int inWrt, Eigen::VectorXd const &last, Eigen::VectorXd const &sens)
 
template<typename... Args>
Eigen::VectorXd const & ApplyJacobian (unsigned int wrtOut, unsigned int wrtIn, Args const &... args)
 
virtual Eigen::VectorXd GradientByFD (unsigned int const outputDimWrt, unsigned int const inputDimWrt, std::vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sensitivity)
 
virtual Eigen::VectorXd GradientByFD (unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sensitivity)
 
virtual Eigen::MatrixXd JacobianByFD (unsigned int const outputDimWrt, unsigned int const inputDimWrt, std::vector< Eigen::VectorXd > const &input)
 
virtual Eigen::MatrixXd JacobianByFD (unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input)
 
virtual Eigen::VectorXd ApplyJacobianByFD (unsigned int const outputDimWrt, unsigned int const inputDimWrt, std::vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &vec)
 
virtual Eigen::VectorXd ApplyJacobianByFD (unsigned int const outputDimWrt, unsigned int const inputDimWrt, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &vec)
 
virtual Eigen::VectorXd const & ApplyHessian (unsigned int const outWrt, unsigned int const inWrt1, unsigned int const inWrt2, std::vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sens, Eigen::VectorXd const &vec)
 
virtual Eigen::VectorXd const & ApplyHessian (unsigned int const outWrt, unsigned int const inWrt1, unsigned int const inWrt2, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sens, Eigen::VectorXd const &vec)
 
virtual Eigen::VectorXd ApplyHessianByFD (unsigned int const outWrt, unsigned int const inWrt1, unsigned int const inWrt2, std::vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sens, Eigen::VectorXd const &vec)
 
virtual Eigen::VectorXd ApplyHessianByFD (unsigned int const outWrt, unsigned int const inWrt1, unsigned int const inWrt2, ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sens, Eigen::VectorXd const &vec)
 
void EnableCache ()
 
void DisableCache ()
 
bool CacheStatus () const
 
virtual void SetWarnLevel (unsigned int newLevel)
 
- Public Member Functions inherited from muq::Modeling::WorkPiece
 WorkPiece ()
 Create a muq::Modeling::WorkPiece with no fixed number of inputs and outputs and variable input/output types. More...
 
 WorkPiece (int const num, WorkPiece::Fix const fix=WorkPiece::Fix::Inputs)
 Create a muq::Modeling::WorkPiece with either a fixed number of inputs or outputs and variable input/output types. More...
 
 WorkPiece (int const numIns, int const numOuts)
 Create a muq::Modeling::WorkPiece with a fixed number of inputs and outputs but variable input/output types. More...
 
 WorkPiece (std::vector< std::string > const &types, WorkPiece::Fix const fix=WorkPiece::Fix::Inputs)
 Create a muq::Modeling::WorkPiece with either a fixed number of inputs with specified types or a fixed number of outputs with specified types. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &types, WorkPiece::Fix const fix=WorkPiece::Fix::Inputs)
 Create a muq::Modeling::WorkPiece where either some of the inputs have specified types or some of the outputs have specified types. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &types, int const num, WorkPiece::Fix const fixTypes=WorkPiece::Fix::Inputs, WorkPiece::Fix const fixNum=WorkPiece::Fix::Inputs)
 Create a muq::Modeling::WorkPiece where either some of the inputs have specified types or some of the outputs have specified types and either the number of inputs or the number of outputs is fixed. More...
 
 WorkPiece (std::vector< std::string > const &types, int const num)
 Create a muq::Modeling::WorkPiece with a fixed number of inputs with specified types and a fixed number of outputs (of uknown type) More...
 
 WorkPiece (int const num, std::vector< std::string > const &types)
 Create a muq::Modeling::WorkPiece with a fixed number of outputs with specified types and a fixed number of inputs (of uknown type) More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, int const numIns, int const numOuts)
 Create a muq::Modeling::WorkPiece where some of the inputs are known and we know the input and output numbers. More...
 
 WorkPiece (int const numIns, std::map< unsigned int, std::string > const &outTypes, int const numOuts)
 Create a muq::Modeling::WorkPiece where some of the outputs are known and we know the input and output numbers. More...
 
 WorkPiece (std::vector< std::string > const &inTypes, std::vector< std::string > const &outTypes)
 Create a muq::Modeling::WorkPiece with a fixed number of inputs and outputs with specified types. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, std::vector< std::string > const &outTypes)
 Create a muq::Modeling::WorkPiece where some of the inputs are known and all of the outputs have specified types. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, int const num, std::vector< std::string > const &outTypes)
 Create a muq::Modeling::WorkPiece where some of the inputs are known with a known number of inputs and all of the outputs have specified types. More...
 
 WorkPiece (std::vector< std::string > const &inTypes, std::map< unsigned int, std::string > const &outTypes)
 Create a muq::Modeling::WorkPiece where some of the outputs and all of the inputs have specified types. More...
 
 WorkPiece (std::vector< std::string > const &inTypes, std::map< unsigned int, std::string > const &outTypes, int const num)
 Create a muq::Modeling::WorkPiece where some of the outputs with a known number of outputs and all of the inputs have specified types. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, std::map< unsigned int, std::string > const &outTypes)
 Create a muq::Mdoeling::WorkPiece where some of the inputs and some of the outputs have specified types. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, int const numIn, std::map< unsigned int, std::string > const &outTypes)
 Create a muq::Mdoeling::WorkPiece where some of the inputs and some of the outputs have specified types with a fixed number of inputs. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, std::map< unsigned int, std::string > const &outTypes, int const numOut)
 Create a muq::Mdoeling::WorkPiece where some of the inputs and some of the outputs have specified types with a fixed number of outputs. More...
 
 WorkPiece (std::map< unsigned int, std::string > const &inTypes, int const numIn, std::map< unsigned int, std::string > const &outTypes, int const numOut)
 Create a muq::Mdoeling::WorkPiece where some of the inputs and some of the outputs have specified types with a fixed number of inputs and outputs. More...
 
virtual ~WorkPiece ()
 Default destructor. More...
 
std::vector< boost::any > const & Evaluate (std::vector< boost::any > const &ins)
 Evaluate this muq::Modeling::WorkPiece. More...
 
std::vector< boost::any > const & Evaluate (ref_vector< boost::any > const &ins)
 Evaluate this muq::Modeling::WorkPiece using references to the inputs. More...
 
std::vector< boost::any > const & Evaluate ()
 Evaluate this muq::Modeling::WorkPiece in the case that there are no inputs. More...
 
template<typename... Args>
std::vector< boost::any > const & Evaluate (Args... args)
 Evalaute this muq::Modeling::WorkPiece using multiple arguments. More...
 
std::string const & Name ()
 Get the (unique) name of this work piece. More...
 
void SetName (std::string const &newName)
 Set the name of this work piece. More...
 
std::string InputType (unsigned int inputNum, bool const demangle=true) const
 Get the input type (if we know it) for a specific input. More...
 
int InputSize (unsigned int inputNum) const
 Get the length of a vector valued input with fixed size. More...
 
void SetInputSize (unsigned int inputNum, int newSize)
 
std::string OutputType (unsigned int outputNum, bool const demangle=true) const
 Get the output type (if we know it) for a specific output. More...
 
std::map< unsigned int, std::string > OutputTypes () const
 Get the output types. More...
 
std::map< unsigned int, std::string > InputTypes () const
 Get the input types. More...
 
unsigned int ID () const
 Get the unique ID number. More...
 

Static Public Member Functions

static std::shared_ptr< BasisExpansionFromHDF5 (std::string filename, std::string groupName="/")
 Loads an expansion from an HDF5 file.
More...
 
static std::shared_ptr< BasisExpansionFromHDF5 (muq::Utilities::H5Object &group)
 Loads the expansion from an existing HDF5 group.
More...
 
- Static Public Member Functions inherited from muq::Modeling::WorkPiece
static ref_vector< const boost::any > ToRefVector (std::vector< boost::any > const &anyVec)
 Create vector of references from a vector of boost::any's. More...
 
static ref_vector< const Eigen::VectorXd > ToRefVector (std::vector< Eigen::VectorXd > const &anyVec)
 

Friends

class MonotoneExpansion
 

Additional Inherited Members

- Public Attributes inherited from muq::Modeling::ModPiece
const Eigen::VectorXi inputSizes
 
const Eigen::VectorXi outputSizes
 
- Public Attributes inherited from muq::Modeling::WorkPiece
int numInputs
 The number of inputs. More...
 
int numOutputs
 The number of outputs. More...
 

Constructor & Destructor Documentation

◆ BasisExpansion() [1/3]

BasisExpansion::BasisExpansion ( std::vector< std::shared_ptr< IndexedScalarBasis >> const &  basisCompsIn,
bool  coeffInput = false 
)

Construct expansion by specifying basis components (i.e., the family for each \(\phi_i\)). Initializes the expansion to a single constant (i.e., \(\alpha=0\)) term with coefficient \(0\).

Definition at line 13 of file BasisExpansion.cpp.

◆ BasisExpansion() [2/3]

BasisExpansion::BasisExpansion ( std::vector< std::shared_ptr< IndexedScalarBasis >> const &  basisCompsIn,
std::shared_ptr< muq::Utilities::MultiIndexSet multisIn,
bool  coeffInput = false 
)

Construct the expansion by specifying both the basis families and multi-indices. Sets all coefficients in the expansion to zero.

Definition at line 20 of file BasisExpansion.cpp.

◆ BasisExpansion() [3/3]

BasisExpansion::BasisExpansion ( std::vector< std::shared_ptr< IndexedScalarBasis >> const &  basisCompsIn,
std::shared_ptr< muq::Utilities::MultiIndexSet multisIn,
Eigen::MatrixXd const &  coeffsIn,
bool  coeffInput = false 
)

Construct the expansion by specifying all ingredients: the basis family, multi-indices, and coefficients.

Definition at line 29 of file BasisExpansion.cpp.

References basisComps, coeffs, and multis.

◆ ~BasisExpansion()

virtual muq::Approximation::BasisExpansion::~BasisExpansion ( )
virtualdefault

Member Function Documentation

◆ BuildDerivMatrix()

Eigen::MatrixXd BasisExpansion::BuildDerivMatrix ( Eigen::MatrixXd const &  evalPts,
int  wrtDim 
) const

Constructs a Vandermonde-like matrix but instead of filling each column with evaluations of the basis function, this function fill each column with the derivatives of a basis function with respect to a particular input. @seealso BuildVandermonde

Definition at line 287 of file BasisExpansion.cpp.

References GetAllDerivs(), and NumTerms().

◆ BuildVandermonde()

Eigen::MatrixXd BasisExpansion::BuildVandermonde ( Eigen::MatrixXd const &  evalPts) const

Constructs a Vandermonde matrix by evaluating the $M$ basis functions at $N$ points stored in the evalPts matrix. Each column of the evalPts input contains a single point. The returned matrix is size $N\times M$.

Definition at line 276 of file BasisExpansion.cpp.

References GetAllTerms(), and NumTerms().

◆ EvaluateImpl()

void BasisExpansion::EvaluateImpl ( muq::Modeling::ref_vector< Eigen::VectorXd > const &  inputs)
overrideprotectedvirtual

◆ FromHDF5() [1/2]

std::shared_ptr< BasisExpansion > BasisExpansion::FromHDF5 ( muq::Utilities::H5Object group)
static

Loads the expansion from an existing HDF5 group.

This function will read the multiindices in an an HDF5 dataset and construct an instance of the MultiIndexSet class.

Parameters
[in]groupAn HDF5 group containing the "multiindices", "coefficients", and "basis_types" datasets.
See also
BasisExpansion::ToHDF5

Definition at line 339 of file BasisExpansion.cpp.

References muq::Utilities::H5Object::attrs, coeffs, muq::Approximation::IndexedScalarBasis::Construct(), muq::Modeling::ModPiece::inputSizes, muq::Modeling::WorkPiece::name, and muq::Utilities::StringUtilities::Split().

◆ FromHDF5() [2/2]

std::shared_ptr< BasisExpansion > BasisExpansion::FromHDF5 ( std::string  filename,
std::string  groupName = "/" 
)
static

Loads an expansion from an HDF5 file.

This function works in tandem with the BasisExpansion::ToHDF5 function. It will read the multiindices, coefficients, and scalar basis type from the HDF5 file and construct a BasisExpansion. See the BasisExpansion::ToHDF5 function for the details of these datasets.

Parameters
[in]filenameA string to an HDF5 file. If the file doesn't exist or the correct datasets don't exist, an exception will be thrown.
[in]dsetNameThe path to the HDF5 group containing expansion datasets.
Returns
std::shared_ptr<BasisExpansion>
See also
BasisExpansion::ToHDF5

Definition at line 333 of file BasisExpansion.cpp.

References muq::Utilities::OpenFile().

Referenced by muq::Approximation::PolynomialChaosExpansion::FromHDF5().

◆ GetAllDerivs()

Eigen::MatrixXd BasisExpansion::GetAllDerivs ( Eigen::VectorXd const &  x) const
protected

Evaluates the first derivatives of all the terms in the expansion

Returns
A matrix of size (numTerms, numDims) containing the derivative of each term wrt each input

Definition at line 92 of file BasisExpansion.cpp.

References basisComps, and multis.

Referenced by BuildDerivMatrix(), JacobianImpl(), and SecondDerivative().

◆ GetAllTerms()

Eigen::VectorXd BasisExpansion::GetAllTerms ( Eigen::VectorXd const &  x) const
protected

Evaluates all the terms in the expansion, but does not multiply by coefficients.

Definition at line 65 of file BasisExpansion.cpp.

References basisComps, and multis.

Referenced by BuildVandermonde(), EvaluateImpl(), and JacobianImpl().

◆ GetCoeffs()

Eigen::MatrixXd BasisExpansion::GetCoeffs ( ) const

Definition at line 266 of file BasisExpansion.cpp.

References coeffs.

◆ GetHessians()

std::vector< Eigen::MatrixXd > BasisExpansion::GetHessians ( Eigen::VectorXd const &  x) const
protected

Computes the Hessian matrix for each output of the expansion.

Definition at line 137 of file BasisExpansion.cpp.

References basisComps, coeffs, nlohmann::detail::dtoa_impl::k, and multis.

Referenced by SecondDerivative().

◆ GetInputSizes()

Eigen::VectorXi BasisExpansion::GetInputSizes ( std::shared_ptr< muq::Utilities::MultiIndexSet multisIn,
Eigen::MatrixXd const &  coeffsIn,
bool  coeffInput 
)
staticprotected

Definition at line 42 of file BasisExpansion.cpp.

◆ GetOutputSizes()

Eigen::VectorXi BasisExpansion::GetOutputSizes ( std::shared_ptr< muq::Utilities::MultiIndexSet multisIn,
Eigen::MatrixXd const &  coeffsIn 
)
staticprotected

Definition at line 58 of file BasisExpansion.cpp.

◆ JacobianImpl()

void BasisExpansion::JacobianImpl ( unsigned int const  wrtIn,
unsigned int const  wrtOut,
muq::Modeling::ref_vector< Eigen::VectorXd > const &  inputs 
)
overrideprotectedvirtual

◆ Multis()

const std::shared_ptr<muq::Utilities::MultiIndexSet> muq::Approximation::BasisExpansion::Multis ( ) const
inline

Definition at line 127 of file BasisExpansion.h.

References multis.

◆ NumTerms()

virtual unsigned muq::Approximation::BasisExpansion::NumTerms ( ) const
inlinevirtual

Returns the number of terms in the expansion. For example, if the expansion is given by \(f(x) = a_1\Phi(x) + a_2\Phi(x)\), this function will return \(2\).

Definition at line 96 of file BasisExpansion.h.

References multis.

Referenced by BuildDerivMatrix(), BuildVandermonde(), and muq::Approximation::PolynomialChaosExpansion::SobolSensitivity().

◆ ProcessCoeffs()

void BasisExpansion::ProcessCoeffs ( Eigen::VectorXd const &  newCoeffs)
protected

Definition at line 200 of file BasisExpansion.cpp.

References coeffs.

Referenced by EvaluateImpl(), and JacobianImpl().

◆ SecondDerivative() [1/2]

Eigen::MatrixXd BasisExpansion::SecondDerivative ( unsigned  outputDim,
unsigned  wrtDim1,
unsigned  wrtDim2,
Eigen::VectorXd const &  evalPt 
)

Definition at line 249 of file BasisExpansion.cpp.

References coeffs, GetAllDerivs(), and GetHessians().

◆ SecondDerivative() [2/2]

Eigen::MatrixXd BasisExpansion::SecondDerivative ( unsigned  outputDim,
unsigned  wrtDim1,
unsigned  wrtDim2,
Eigen::VectorXd const &  evalPt,
Eigen::MatrixXd const &  coeffs 
)

Definition at line 239 of file BasisExpansion.cpp.

References SetCoeffs().

◆ SetCoeffs()

void BasisExpansion::SetCoeffs ( Eigen::MatrixXd const &  allCoeffs)

Definition at line 270 of file BasisExpansion.cpp.

References coeffs.

Referenced by SecondDerivative().

◆ ToHDF5() [1/2]

void BasisExpansion::ToHDF5 ( muq::Utilities::H5Object group) const
virtual

Saves the expansion to a group in an HDF5 file.

This function will create three datasets in an HDF5 group to save the multiindices, coefficients, and type of scalar basis functions used to define this expansion. The datasets will be named "multiindices", "coefficients", and "basis_types" and put in a group given as an argument to this function. The multiindices dataset will contain an \(N\times D_{in}\) matrix of integers, the coefficients dataset will contain a \(D_{out}\times N\) matrix of doubles, and the basis_types dataset will contain a length \(D_{in}\) list of strings. The strings correspond to the name of the scalar basis functions, which can be passed to the IndexedScalarBasis::Construct function.

Parameters
[in]groupAn HDF5 object for the group where the datasets will be created.

Reimplemented in muq::Approximation::PolynomialChaosExpansion.

Definition at line 304 of file BasisExpansion.cpp.

References muq::Utilities::H5Object::attrs, basisComps, coeffs, muq::Utilities::StringUtilities::Combine(), muq::Utilities::H5Object::CreateDataset(), muq::Approximation::IndexedScalarBasis::GetScalarBasisMap(), muq::Utilities::GetTypeName(), muq::Modeling::ModPiece::inputSizes, and multis.

◆ ToHDF5() [2/2]

void BasisExpansion::ToHDF5 ( std::string  filename,
std::string  groupName = "/" 
) const
virtual

Saves the expansion to group in an HDF5 file.

This function will create three datasets in an HDF5 file to save the multiindices, coefficients, and type of scalar basis functions used to define this expansion. The datasets will be named "multiindices", "coefficients", and "basis_type" and put in a group given as an argument to this function. The multiindices dataset will contain an \(N\times D_{in}\) matrix of integers, the coefficients dataset will contain a \(D_{out}\times N\) matrix of doubles, and the basis_type dataset will contain a length \(D_{in}\) list of strings. The strings correspond to the name of the scalar basis functions, which can be passed to the IndexedScalarBasis::Construct function.

Parameters
[in]filenameA string to the HDF5 file that this multiindexset should be stored in. If the file doesn't exist, it will be created.
[in]groupNameThe path to the group in the HDF5 file where expansion datasets should be created. Defaults to the root "/".

Definition at line 298 of file BasisExpansion.cpp.

References muq::Utilities::OpenFile().

Referenced by muq::Approximation::PolynomialChaosExpansion::ToHDF5().

Friends And Related Function Documentation

◆ MonotoneExpansion

friend class MonotoneExpansion
friend

Definition at line 66 of file BasisExpansion.h.

Member Data Documentation

◆ basisComps

◆ coeffs

◆ multis


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