Ensign
Low-rank framework for multi-core CPUs and GPUs
Loading...
Searching...
No Matches
Ensign Namespace Reference

Core namespace for Ensign's numerical algorithms and data structures. More...

Namespaces

namespace  gt
 Named and aggregated timers for profiling code sections.
 
namespace  IndexFunction
 Conversion and iteration helpers for multidimensional indices.
 
namespace  Matrix
 Dense matrix operations.
 
namespace  Tensor
 Tensor matricization, tensorization, and orthogonalization operations.
 

Classes

struct  external_node
 Represents a leaf tree node with a basis matrix. More...
 
struct  fft
 FFT for arbitrary dimensional data, specified by dim. More...
 
struct  internal_node
 Represents an internal tree node with a coefficient tensor. More...
 
struct  lr2
 Class to store the low-rank factors (X, S, V) that are used in the computation. More...
 
struct  multi_array
 Dense d-dimensional array stored contiguously in column-major order (i.e. More...
 
struct  nc_writer
 Writes simulation variables and dimension metadata to a NetCDF file. More...
 
struct  node
 Base class for a node in a tree tensor network. More...
 
struct  orthogonalize
 Orthogonalizes Q and returns the corresponding upper triangular matrix R. More...
 
struct  timer
 This timer class measures the elapsed time between two events. More...
 

Typedefs

template<size_t d>
using fft3d = fft< d, 3 >
 
template<size_t d>
using fft2d = fft< d, 2 >
 
template<size_t d>
using fft1d = fft< d, 1 >
 

Functions

template<typename T , typename... Args>
std::unique_ptr< T > make_unique_ptr (Args &&... args)
 
array< fftw_plan, 2 > create_plans_1d (Index dims_, multi_array< double, 2 > &real, multi_array< complex< double >, 2 > &freq)
 Helper routines to create FFTW plans for 1d transforms.
 
array< fftw_plan, 2 > create_plans_1d (Index dims_, multi_array< double, 1 > &real, multi_array< complex< double >, 1 > &freq)
 
array< fftw_plan, 2 > create_plans_2d (array< Index, 2 > dims_, multi_array< double, 1 > &real, multi_array< complex< double >, 1 > &freq)
 Helper routines to create FFTW plans for 2d transforms.
 
array< fftw_plan, 2 > create_plans_2d (array< Index, 2 > dims_, multi_array< double, 2 > &real, multi_array< complex< double >, 2 > &freq)
 
array< fftw_plan, 2 > create_plans_3d (array< Index, 3 > dims_, multi_array< double, 2 > &real, multi_array< complex< double >, 2 > &freq)
 Helper routines to create FFTW plans for 3d transforms.
 
array< fftw_plan, 2 > create_plans_3d (array< Index, 3 > dims_, multi_array< double, 1 > &real, multi_array< complex< double >, 1 > &freq)
 
array< fftw_plan, 2 > create_plans_3d_adapt (array< Index, 3 > dims_, multi_array< double, 2 > &real, multi_array< complex< double >, 2 > &freq)
 
void destroy_plans (array< fftw_plan, 2 > &plans)
 Helper function to destroy FFTW plans.
 
template<size_t d>
void dump (string fn, const multi_array< double, d > &ma)
 
template<size_t d>
void dump (string fn, const multi_array< complex< double >, d > &ma)
 
template<class T >
void print (const multi_array< T, 2 > &ma)
 
template<class T , size_t d>
T prod (array< T, d > a)
 
template<class T >
T phi1 (T a)
 Computes (exp(z)-1)/z.
 
template<class T >
T phi1_im (T a)
 Computes (exp(i a)-1)/(i a)
 
template<class T >
T phi2_im (T a)
 Computes (exp(i a)-1-i a)/((i a)^2)
 
template<size_t d>
array< Index, d > parse (string s)
 Parser for command line arguments separated by whitespaces.
 
template<class T >
double max_err (T err, T diff)
 Maximum function which treats NaNs correctly.
 
template<class InputIt , class OutputIt >
void remove_element (InputIt first, InputIt last, OutputIt d_first, const Index idx)
 
template<class T >
void coeff (const multi_array< T, 2 > &a, const multi_array< T, 2 > &b, T w, multi_array< T, 2 > &out, const Ensign::Matrix::blas_ops &blas)
 Computes a low-rank coefficient that approximates \(\int a_i(x) b_j(x) \,dx\).
 
template<class T >
void coeff (const multi_array< T, 2 > &a, const multi_array< T, 2 > &b, const multi_array< T, 1 > &w, multi_array< T, 2 > &out, const Ensign::Matrix::blas_ops &blas)
 Computes a low-rank coefficient that approximates \(\int a_i(x) b_j(x) \,dx\).
 
template<class T >
void integrate (const multi_array< T, 2 > &a, T w, multi_array< T, 1 > &out, const Ensign::Matrix::blas_ops &blas)
 Computes an approximation to the integral \(\int a_i(x) \,dx\).
 
template<class T >
void integrate (const multi_array< T, 2 > &a, const multi_array< T, 1 > &w, multi_array< T, 1 > &out, const Ensign::Matrix::blas_ops &blas)
 Computes an approximation to the integral \(\int a_i(x) \,dx\).
 
template<class T >
void coeff (const multi_array< T, 2 > &a, const multi_array< T, 2 > &b, const multi_array< T, 2 > &c, T w, multi_array< T, 3 > &out, const Ensign::Matrix::blas_ops &blas)
 Computes a low-rank coefficient that approximates \(\int a_i(x) b_j(x) b_k(x) \,dx\).
 
void deim_ext (const multi_array< double, 2 > &_U, Index r, multi_array< Index, 1 > &I)
 
double colloquation_to_lr (const multi_array< double, 2 > &f_I, multi_array< double, 2 > &f_J, const multi_array< Index, 1 > &I, multi_array< double, 2 > &X, multi_array< double, 2 > &L, Matrix::blas_ops &blas)
 
double colloquation_to_lr (const multi_array< double, 2 > &f_I, multi_array< double, 2 > &f_J, const multi_array< Index, 1 > &I, lr2< double > &f, Matrix::blas_ops &blas)
 
template<class T , class IP >
void lr_add (T alpha, const lr2< T > &A, T beta, const lr2< T > &B, lr2< T > &out, IP inner_product_X, IP inner_product_V, const Ensign::Matrix::blas_ops &blas)
 Add two low-rank representations together.
 
template<class T , class IP >
void lr_add (T alpha, const lr2< T > &A, T beta, const lr2< T > &B, T gamma, const lr2< T > &C, lr2< T > &out, IP inner_product_X, IP inner_product_V, const Ensign::Matrix::blas_ops &blas)
 Add three low-rank representations together.
 
template<class T , class IP >
void lr_mul (const lr2< T > &A, const lr2< T > &B, lr2< T > &out, IP inner_product_X, IP inner_product_V, const Ensign::Matrix::blas_ops &blas)
 Multiplies two low-rank representations together.
 
template<class T >
void lr_truncate (const lr2< T > &in, lr2< T > &out, const Ensign::Matrix::blas_ops &blas)
 Truncate a low-rank representation inplace to a fixed rank r.
 
template<class T >
double lr_inner_product (const lr2< T > &A, const lr2< T > &B, T w, const Ensign::Matrix::blas_ops &blas)
 Computes the inner product of two low-rank representations.
 
template<class T >
double lr_norm_sq (const lr2< T > &A, const Ensign::Matrix::blas_ops &blas)
 Computes the norm of a low-rank representations.
 
template<class T , class IP >
void initialize (lr2< T > &lr, vector< const T * > X, vector< const T * > V, IP inner_product_X, IP inner_product_V, const Ensign::Matrix::blas_ops &blas)
 Initializes (an already allocated) lr2 to \(\sum_i X_i V_i\).
 
template<class T >
void initialize (lr2< T > &lr, vector< const T * > X, vector< const T * > V, array< double, 3 > h_xx, array< double, 3 > h_vv, const Ensign::Matrix::blas_ops &blas)
 
template<class T >
std::function< T(T *, T *)> inner_product_from_const_weight (T w, Index N)
 Return an inner product function object for use in, e.g., in gram_schmidt.
 
template<class T >
std::function< T(T *, T *)> inner_product_from_weight (const T *w, Index N)
 Return an inner product function object for use in, e.g., in gram_schmidt.
 

Detailed Description

Core namespace for Ensign's numerical algorithms and data structures.

Typedef Documentation

◆ fft1d

template<size_t d>
using Ensign::fft1d = typedef fft<d, 1>

Definition at line 52 of file fft.hpp.

◆ fft2d

template<size_t d>
using Ensign::fft2d = typedef fft<d, 2>

Definition at line 49 of file fft.hpp.

◆ fft3d

template<size_t d>
using Ensign::fft3d = typedef fft<d, 3>

Definition at line 46 of file fft.hpp.

Function Documentation

◆ coeff() [1/3]

template<class T >
void Ensign::coeff ( const multi_array< T, 2 > &  a,
const multi_array< T, 2 > &  b,
const multi_array< T, 1 > &  w,
multi_array< T, 2 > &  out,
const Ensign::Matrix::blas_ops &  blas 
)

Computes a low-rank coefficient that approximates \(\int a_i(x) b_j(x) \,dx\).

If a and b are of size (n,r) then w must be of size n. The weight w can be used as a pure weight (in a quadrature sense) but also can incooperate a x dependent function.

◆ coeff() [2/3]

template<class T >
void Ensign::coeff ( const multi_array< T, 2 > &  a,
const multi_array< T, 2 > &  b,
const multi_array< T, 2 > &  c,
T  w,
multi_array< T, 3 > &  out,
const Ensign::Matrix::blas_ops &  blas 
)

Computes a low-rank coefficient that approximates \(\int a_i(x) b_j(x) b_k(x) \,dx\).

This function assumes that w is a constant weight.

◆ coeff() [3/3]

template<class T >
void Ensign::coeff ( const multi_array< T, 2 > &  a,
const multi_array< T, 2 > &  b,
T  w,
multi_array< T, 2 > &  out,
const Ensign::Matrix::blas_ops &  blas 
)

Computes a low-rank coefficient that approximates \(\int a_i(x) b_j(x) \,dx\).

This functions assumes that w is a constant weight.

◆ colloquation_to_lr() [1/2]

double Ensign::colloquation_to_lr ( const multi_array< double, 2 > &  f_I,
multi_array< double, 2 > &  f_J,
const multi_array< Index, 1 > &  I,
lr2< double > &  f,
Matrix::blas_ops &  blas 
)

◆ colloquation_to_lr() [2/2]

double Ensign::colloquation_to_lr ( const multi_array< double, 2 > &  f_I,
multi_array< double, 2 > &  f_J,
const multi_array< Index, 1 > &  I,
multi_array< double, 2 > &  X,
multi_array< double, 2 > &  L,
Matrix::blas_ops &  blas 
)

◆ create_plans_1d() [1/2]

array< fftw_plan, 2 > Ensign::create_plans_1d ( Index  dims_,
multi_array< double, 1 > &  real,
multi_array< complex< double >, 1 > &  freq 
)

◆ create_plans_1d() [2/2]

array< fftw_plan, 2 > Ensign::create_plans_1d ( Index  dims_,
multi_array< double, 2 > &  real,
multi_array< complex< double >, 2 > &  freq 
)

Helper routines to create FFTW plans for 1d transforms.

◆ create_plans_2d() [1/2]

array< fftw_plan, 2 > Ensign::create_plans_2d ( array< Index, 2 >  dims_,
multi_array< double, 1 > &  real,
multi_array< complex< double >, 1 > &  freq 
)

Helper routines to create FFTW plans for 2d transforms.

◆ create_plans_2d() [2/2]

array< fftw_plan, 2 > Ensign::create_plans_2d ( array< Index, 2 >  dims_,
multi_array< double, 2 > &  real,
multi_array< complex< double >, 2 > &  freq 
)

◆ create_plans_3d() [1/2]

array< fftw_plan, 2 > Ensign::create_plans_3d ( array< Index, 3 >  dims_,
multi_array< double, 1 > &  real,
multi_array< complex< double >, 1 > &  freq 
)

◆ create_plans_3d() [2/2]

array< fftw_plan, 2 > Ensign::create_plans_3d ( array< Index, 3 >  dims_,
multi_array< double, 2 > &  real,
multi_array< complex< double >, 2 > &  freq 
)

Helper routines to create FFTW plans for 3d transforms.

◆ create_plans_3d_adapt()

array< fftw_plan, 2 > Ensign::create_plans_3d_adapt ( array< Index, 3 >  dims_,
multi_array< double, 2 > &  real,
multi_array< complex< double >, 2 > &  freq 
)

◆ deim_ext()

void Ensign::deim_ext ( const multi_array< double, 2 > &  _U,
Index  r,
multi_array< Index, 1 > &  I 
)

◆ destroy_plans()

void Ensign::destroy_plans ( array< fftw_plan, 2 > &  plans)

Helper function to destroy FFTW plans.

◆ dump() [1/2]

template<size_t d>
void Ensign::dump ( string  fn,
const multi_array< complex< double >, d > &  ma 
)

Definition at line 506 of file storage.hpp.

◆ dump() [2/2]

template<size_t d>
void Ensign::dump ( string  fn,
const multi_array< double, d > &  ma 
)

Definition at line 494 of file storage.hpp.

◆ initialize() [1/2]

template<class T >
void Ensign::initialize ( lr2< T > &  lr,
vector< const T * >  X,
vector< const T * >  V,
array< double, 3 >  h_xx,
array< double, 3 >  h_vv,
const Ensign::Matrix::blas_ops &  blas 
)

◆ initialize() [2/2]

template<class T , class IP >
void Ensign::initialize ( lr2< T > &  lr,
vector< const T * >  X,
vector< const T * >  V,
IP  inner_product_X,
IP  inner_product_V,
const Ensign::Matrix::blas_ops &  blas 
)

Initializes (an already allocated) lr2 to \(\sum_i X_i V_i\).

The rank r is taken from the initialized lr. If X.size() and V.size() are smaller than r, the remaining basis functions are initialized in a random manner (subject (to the orthogonality condition). X.size() == V.size() is required.

◆ inner_product_from_const_weight()

template<class T >
std::function< T(T *, T *)> Ensign::inner_product_from_const_weight ( T  w,
Index  N 
)

Return an inner product function object for use in, e.g., in gram_schmidt.

◆ inner_product_from_weight()

template<class T >
std::function< T(T *, T *)> Ensign::inner_product_from_weight ( const T *  w,
Index  N 
)

Return an inner product function object for use in, e.g., in gram_schmidt.

◆ integrate() [1/2]

template<class T >
void Ensign::integrate ( const multi_array< T, 2 > &  a,
const multi_array< T, 1 > &  w,
multi_array< T, 1 > &  out,
const Ensign::Matrix::blas_ops &  blas 
)

Computes an approximation to the integral \(\int a_i(x) \,dx\).

If a is of size (n,r) then w must be a contiguous memory region of size n. The weight w can be used as a pure weight (in a quadrature sense) but also can incooperate a x dependent function.

◆ integrate() [2/2]

template<class T >
void Ensign::integrate ( const multi_array< T, 2 > &  a,
T  w,
multi_array< T, 1 > &  out,
const Ensign::Matrix::blas_ops &  blas 
)

Computes an approximation to the integral \(\int a_i(x) \,dx\).

This function assumes that w is a constant weight.

◆ lr_add() [1/2]

template<class T , class IP >
void Ensign::lr_add ( T  alpha,
const lr2< T > &  A,
T  beta,
const lr2< T > &  B,
lr2< T > &  out,
IP  inner_product_X,
IP  inner_product_V,
const Ensign::Matrix::blas_ops &  blas 
)

Add two low-rank representations together.

Note that no truncation is performed by this function. To do that call lr_truncate.

◆ lr_add() [2/2]

template<class T , class IP >
void Ensign::lr_add ( T  alpha,
const lr2< T > &  A,
T  beta,
const lr2< T > &  B,
T  gamma,
const lr2< T > &  C,
lr2< T > &  out,
IP  inner_product_X,
IP  inner_product_V,
const Ensign::Matrix::blas_ops &  blas 
)

Add three low-rank representations together.

Note that no truncation is performed by this function. To do that call lr_truncate.

◆ lr_inner_product()

template<class T >
double Ensign::lr_inner_product ( const lr2< T > &  A,
const lr2< T > &  B,
T  w,
const Ensign::Matrix::blas_ops &  blas 
)

Computes the inner product of two low-rank representations.

Computes the inner product of two low-rank representations.

◆ lr_mul()

template<class T , class IP >
void Ensign::lr_mul ( const lr2< T > &  A,
const lr2< T > &  B,
lr2< T > &  out,
IP  inner_product_X,
IP  inner_product_V,
const Ensign::Matrix::blas_ops &  blas 
)

Multiplies two low-rank representations together.

Note that no truncation is performed by this function. To do that call lr_truncate.

◆ lr_norm_sq()

template<class T >
double Ensign::lr_norm_sq ( const lr2< T > &  A,
const Ensign::Matrix::blas_ops &  blas 
)

Computes the norm of a low-rank representations.

This assumes that X and V are orthogonalized. Thus, no inner product needs to be passed to this function. The function simply computes \(\sum_{ij} S_{ij}^2\)

◆ lr_truncate()

template<class T >
void Ensign::lr_truncate ( const lr2< T > &  in,
lr2< T > &  out,
const Ensign::Matrix::blas_ops &  blas 
)

Truncate a low-rank representation inplace to a fixed rank r.

The rank is determined by the size of out.

◆ make_unique_ptr()

template<typename T , typename... Args>
std::unique_ptr< T > Ensign::make_unique_ptr ( Args &&...  args)

Definition at line 100 of file common.hpp.

◆ max_err()

template<class T >
double Ensign::max_err ( T  err,
T  diff 
)

Maximum function which treats NaNs correctly.

Definition at line 87 of file utility.hpp.

◆ parse()

template<size_t d>
array< Index, d > Ensign::parse ( string  s)

Parser for command line arguments separated by whitespaces.

Definition at line 66 of file utility.hpp.

◆ phi1()

template<class T >
T Ensign::phi1 ( T  a)

Computes (exp(z)-1)/z.

There is a removeable singularity at z=0.

Definition at line 26 of file utility.hpp.

◆ phi1_im()

template<class T >
T Ensign::phi1_im ( T  a)

Computes (exp(i a)-1)/(i a)

There is a removeable singularity at a=0.

Definition at line 35 of file utility.hpp.

◆ phi2_im()

template<class T >
T Ensign::phi2_im ( T  a)

Computes (exp(i a)-1-i a)/((i a)^2)

There is a removeable singularity at a=0.

Definition at line 48 of file utility.hpp.

◆ print()

template<class T >
void Ensign::print ( const multi_array< T, 2 > &  ma)

Definition at line 518 of file storage.hpp.

◆ prod()

template<class T , size_t d>
T Ensign::prod ( array< T, d >  a)

Definition at line 14 of file utility.hpp.

◆ remove_element()

template<class InputIt , class OutputIt >
void Ensign::remove_element ( InputIt  first,
InputIt  last,
OutputIt  d_first,
const Index  idx 
)

Definition at line 95 of file utility.hpp.