UQTk: Uncertainty Quantification Toolkit 3.1.5
KLDecompUni Class Reference

Computes the Karhunen-Loeve decomposition of a univariate stochastic process. More...

#include <kle.h>

Public Member Functions

 KLDecompUni (const Array1D< double > &tSamples)
 Constructor that takes the autocorrelation matrix "corr" ( $C$) of the process we are studying as well as the array "tsamples" ( $t$) with the points in time where snapshots of the system were taken.
 
 KLDecompUni ()
 
 ~KLDecompUni ()
 Destructor.
 
void Init ()
 
void SetWeights (const Array1D< double > &weights)
 Set weights for computing the integral needed for Nystrom's method for solving the Fredholm integral equation.
 
void SetWeights (const double *weights, const int npts)
 Set weights for computing the integral needed for Nystrom's method for solving the Fredholm integral equation.
 
int decompose (const Array2D< double > &corr, const int &nKL)
 Perform KL decomposition into nKL modes and return actual number of modes that were obtained.
 
int decompose (const double *corr, const int &nKL)
 Perform KL decomposition into nKL modes and return actual number of modes that were obtained.
 
void KLproject (const Array2D< double > &realiz, Array2D< double > &xi)
 Project realizations $F(t,\theta_l)$ to the KL modes and store them in xi ( $\xi_k$)
 
const Array1D< double > & eigenvalues () const
 Get eigenvalues in descending order.
 
void eigenvalues (const int nEIG, double *eigs) const
 
const Array2D< double > & KLmodes () const
 Get associated KL modes.
 
void KLmodes (const int npts, const int nKL, double *klModes) const
 Get associated KL modes.
 
void meanRealiz (const Array2D< double > &realiz, Array1D< double > &mean_realiz)
 Calculate (in meanRealiz) the mean realizations.
 
void truncRealiz (const Array1D< double > &meanrea, const Array2D< double > &xi, const int &nKL, Array2D< double > &trunc_realiz)
 Returns the truncated KL sum.
 

Private Member Functions

 KLDecompUni (const KLDecompUni &)
 Dummy default constructor, which should not be used as it is not well defined.
 

Private Attributes

bool decomposed_
 Flag to determine whether KL decomposition has taken place (and consequently that the interal data structures contain meaningful eigenvalues and vectors ... )
 
Array2D< double > whcwh_
 Matrix to hold the upper triangular part of the matrix to get eigenvalues of.
 
Array1D< double > w_
 Array to hold weights for Nystrom's method for Fredholm integral equation solution.
 
Array1D< double > wh_
 Array to hold square roots of weights.
 
char jobz_
 Option to determine what to compute (eigenvalues and eigenvectors)
 
char eigRange_
 Option to set the type of range for eigenvalues.
 
char uplo_
 Option to indicate how matrix is stored.
 
double vl_
 Lower bound for range of eigenvalues.
 
double vu_
 Upper bound for range of eigenvalues.
 
int il_
 Lower index of range of eigenvalues requested.
 
int iu_
 Upper index of range of eigenvalues requested.
 
double absTol_
 Absolute tolerance for convergence.
 
Array1D< double > eig_values_
 Array to store eigenvalues.
 
Array2D< double > KL_modes_
 Matrix to store KL modes.
 
int eig_info_
 info on success of the eigenvector solutions
 
Array1D< int > ifail_
 Array to store indices of eigenvectors that failed to converge.
 

Detailed Description

Computes the Karhunen-Loeve decomposition of a univariate stochastic process.

\[
F(t,\theta) = \left < F(t,\theta) \right >_{\theta}
              + \sum_{k=1}^{\infty} \sqrt{\lambda_k} f_k(t) \xi_k\]

Constructor & Destructor Documentation

◆ KLDecompUni() [1/3]

KLDecompUni::KLDecompUni ( const Array1D< double > & tSamples)

Constructor that takes the autocorrelation matrix "corr" ( $C$) of the process we are studying as well as the array "tsamples" ( $t$) with the points in time where snapshots of the system were taken.

Constructs weights ( $w$) needed for the Nystrom method to solve the Fredholm integral equation

\[ \int C(s,t)f(t)dt=\lambda f(s) \rightarrow \sum w_j C(s_i,t_j) f_k(t_j) = \lambda_k f_k(s_i)\]

◆ KLDecompUni() [2/3]

KLDecompUni::KLDecompUni ( )

◆ ~KLDecompUni()

KLDecompUni::~KLDecompUni ( )
inline

Destructor.

◆ KLDecompUni() [3/3]

KLDecompUni::KLDecompUni ( const KLDecompUni & )
inlineprivate

Dummy default constructor, which should not be used as it is not well defined.

Dummy copy constructor, which should not be used as it is currently not well defined

Member Function Documentation

◆ decompose() [1/2]

int KLDecompUni::decompose ( const Array2D< double > & corr,
const int & nKL )

Perform KL decomposition into nKL modes and return actual number of modes that were obtained.

Further manipulation of the discretized Fredholm equation leads to the eigenvalue problem

\[A g=\lambda g \]

where $A=W K W$ and $g=Wf$, with $W$ being the diagonal matrix, $W_{ii}=\sqrt{w_i}$ and $K_{ij}=Cov(t_i,t_j)$. Solutions consist of pairs of eigenvalues $\lambda_k$ and KL modes $f_k=W^{-1}g_k$.

◆ decompose() [2/2]

int KLDecompUni::decompose ( const double * corr,
const int & nKL )

Perform KL decomposition into nKL modes and return actual number of modes that were obtained.

Further manipulation of the discretized Fredholm equation leads to the eigenvalue problem

\[A g=\lambda g \]

where $A=W K W$ and $g=Wf$, with $W$ being the diagonal matrix, $W_{ii}=\sqrt{w_i}$ and $K_{ij}=Cov(t_i,t_j)$. Solutions consist of pairs of eigenvalues $\lambda_k$ and KL modes $f_k=W^{-1}g_k$.

◆ eigenvalues() [1/2]

const Array1D< double > & KLDecompUni::eigenvalues ( ) const

Get eigenvalues in descending order.

◆ eigenvalues() [2/2]

void KLDecompUni::eigenvalues ( const int nEIG,
double * eigs ) const

◆ Init()

void KLDecompUni::Init ( )

◆ KLmodes() [1/2]

const Array2D< double > & KLDecompUni::KLmodes ( ) const

Get associated KL modes.

◆ KLmodes() [2/2]

void KLDecompUni::KLmodes ( const int npts,
const int nKL,
double * klModes ) const

Get associated KL modes.

◆ KLproject()

void KLDecompUni::KLproject ( const Array2D< double > & realiz,
Array2D< double > & xi )

Project realizations $F(t,\theta_l)$ to the KL modes and store them in xi ( $\xi_k$)

Samples of random variables $\xi_k$ are obtained by projecting realizations of the random process $F$ on the eigenmodes $f_k$

\[ \left.\xi_k\right\vert_{\theta_l}=\left <F(t,\theta_l)-\left <
  F(t,\theta) \right >_{\theta}, f_k(t) \right >_t/\sqrt{\lambda_k} \]

... or numerically

\[
\left.\xi_k\right\vert_{\theta_l}=\sum_{i=1}^{N_p} w_i\left(F(t_i,\theta_l)-\left <
  F(t_i,\theta) \right >_{\theta} \right) f_k(t_i)/\sqrt{\lambda_k} \]

◆ meanRealiz()

void KLDecompUni::meanRealiz ( const Array2D< double > & realiz,
Array1D< double > & mean_realiz )

Calculate (in meanRealiz) the mean realizations.

◆ SetWeights() [1/2]

void KLDecompUni::SetWeights ( const Array1D< double > & weights)

Set weights for computing the integral needed for Nystrom's method for solving the Fredholm integral equation.

◆ SetWeights() [2/2]

void KLDecompUni::SetWeights ( const double * weights,
const int npts )

Set weights for computing the integral needed for Nystrom's method for solving the Fredholm integral equation.

◆ truncRealiz()

void KLDecompUni::truncRealiz ( const Array1D< double > & meanrea,
const Array2D< double > & xi,
const int & nKL,
Array2D< double > & trunc_realiz )

Returns the truncated KL sum.

\[
  F(t_i,\theta_l) = \left < F(t_i,\theta) \right >_{\theta}
                        + \sum_{k=1}^{nKL} \sqrt{\lambda_k} f_k(t_i) \left. \xi_k\right\vert_{\theta_l}

\]

Member Data Documentation

◆ absTol_

double KLDecompUni::absTol_
private

Absolute tolerance for convergence.

◆ decomposed_

bool KLDecompUni::decomposed_
private

Flag to determine whether KL decomposition has taken place (and consequently that the interal data structures contain meaningful eigenvalues and vectors ... )

◆ eig_info_

int KLDecompUni::eig_info_
private

info on success of the eigenvector solutions

◆ eig_values_

Array1D<double> KLDecompUni::eig_values_
private

Array to store eigenvalues.

◆ eigRange_

char KLDecompUni::eigRange_
private

Option to set the type of range for eigenvalues.

◆ ifail_

Array1D<int> KLDecompUni::ifail_
private

Array to store indices of eigenvectors that failed to converge.

◆ il_

int KLDecompUni::il_
private

Lower index of range of eigenvalues requested.

◆ iu_

int KLDecompUni::iu_
private

Upper index of range of eigenvalues requested.

◆ jobz_

char KLDecompUni::jobz_
private

Option to determine what to compute (eigenvalues and eigenvectors)

◆ KL_modes_

Array2D<double> KLDecompUni::KL_modes_
private

Matrix to store KL modes.

◆ uplo_

char KLDecompUni::uplo_
private

Option to indicate how matrix is stored.

◆ vl_

double KLDecompUni::vl_
private

Lower bound for range of eigenvalues.

◆ vu_

double KLDecompUni::vu_
private

Upper bound for range of eigenvalues.

◆ w_

Array1D<double> KLDecompUni::w_
private

Array to hold weights for Nystrom's method for Fredholm integral equation solution.

◆ wh_

Array1D<double> KLDecompUni::wh_
private

Array to hold square roots of weights.

◆ whcwh_

Array2D<double> KLDecompUni::whcwh_
private

Matrix to hold the upper triangular part of the matrix to get eigenvalues of.


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