WaveBlocksND
Classes | Typedefs | Functions
waveblocks::utilities Namespace Reference

Classes

struct  FunctionMatrixEvaluator
 
struct  FunctionMatrixEvaluator< 1, 1, M, A, R, F >
 
class  MatrixToGrid
 Adaptor which accepts an Eigen::Matrix and emulates some behavior of a std::vector. More...
 
class  MatrixToGridIterator
 Forward iterator for the MatrixToGrid class. More...
 
struct  PacketToCoefficients
 
struct  PacketToCoefficients< wavepackets::ScalarHaWp< D, MultiIndex > >
 
struct  Squeeze
 
struct  Squeeze< 1, CMatrix< 1, Eigen::Dynamic > >
 
struct  Squeeze< 1, T >
 
struct  Squeeze< D, CMatrix< D, Eigen::Dynamic > >
 
class  Timer
 
struct  Unsqueeze
 
struct  Unsqueeze< 1, T >
 

Typedefs

template<class Matrix >
using grid_element_type = GVector< typename Matrix::Scalar, Matrix::RowsAtCompileTime >
 

Functions

template<class Matrix , template< typename... > class Grid = std::vector>
Grid< grid_element_type< Matrix > > matrix_to_grid (const Matrix &m)
 Copies a Eigen::Matrix into a grid. More...
 
template<class Matrix , template< typename... > class Grid = std::vector>
Matrix grid_to_matrix (Grid< grid_element_type< Matrix > > g)
 Copies a grid into a Eigen::Matrix. More...
 
bool parse_complex (char const *text, std::complex< double > &result)
 
template<class A , class R , template< typename... > class G_in = std::vector, template< typename... > class G_out = G_in, template< typename... > class F = std::function>
G_out< R > evaluate_function_in_grid (const F< R(A)> &f, const G_in< A > &g)
 Evaluate a function in multiple points at once. More...
 
template<class T >
std::string to_string (T in)
 

Typedef Documentation

template<class Matrix >
using waveblocks::utilities::grid_element_type = typedef GVector<typename Matrix::Scalar, Matrix::RowsAtCompileTime>

Function Documentation

template<class A , class R , template< typename... > class G_in = std::vector, template< typename... > class G_out = G_in, template< typename... > class F = std::function>
G_out<R> waveblocks::utilities::evaluate_function_in_grid ( const F< R(A)> &  f,
const G_in< A > &  g 
)

Evaluate a function in multiple points at once.

Generic template to evaluate a function object in multiple points

Parameters
fFunction object taking input of type A and returning type R
ggrid (template G_in) of A elements
Returns
grid (template G_out) of R elements
Template Parameters
AType of the argument to be passed to f
RReturn type of f
G_inclass template for a container which implements size() and allows for:in loops
G_outclass template for a container which implements a constructor with a single size_t argument and implements begin() to return a forward-iterator
Fclass template for a function object
template<class Matrix , template< typename... > class Grid = std::vector>
Matrix waveblocks::utilities::grid_to_matrix ( Grid< grid_element_type< Matrix > >  g)

Copies a grid into a Eigen::Matrix.

Builds a matrix from a grid of row vectors

Parameters
gGrid of row vectors
Returns
Matrix with these row vectors
Template Parameters
MatrixThe type of matrix to use for return
GridClass template of the grid to adapt
template<class Matrix , template< typename... > class Grid = std::vector>
Grid<grid_element_type<Matrix> > waveblocks::utilities::matrix_to_grid ( const Matrix &  m)

Copies a Eigen::Matrix into a grid.

Builds a grid of row vectors from a matrix

Parameters
mThe matrix to copy into a grid
Returns
Grid of row vectors
Template Parameters
MatrixThe type of matrix to adapt
GridClass template to use for return
bool waveblocks::utilities::parse_complex ( char const *  text,
std::complex< double > &  result 
)

This function basically invokes std::strtod until end of string and accumulates those comverted numbers.

If one of the characters 'i', 'j','I', 'J' immediately follows after std::strtod, the value is interpreted as a complex number.

Be aware, that this function does not check input properly. Thus for pathological input you get unexpected results, but this function is able to correctly interpret output of python/numpy.

Valid input: "1.0+2.0j" yields (1.0,2.0) "0.7j+1.1+2.2+3.3" yields (6.6,0.7) "1e3-1.7e-3j" yield (1000,-0.0017)

Invalid input: "-+2.0"

Parameters
textzero-terminated c-string
resultVariable holding the result
template<class T >
std::string waveblocks::utilities::to_string ( in)