lambda-lanczos 2.0.0
Loading...
Searching...
No Matches
lambda_lanczos::util Namespace Reference

Classes

class  MapValueIterable
 
struct  realTypeMap
 Template class to map specific types. See real_t<T> for usage. More...
 
struct  realTypeMap< std::complex< T > >
 
class  TupleViewIterator
 Iterator for a container of tuples to iterate over the I-th tuple elements. More...
 
struct  TypedConjugate
 Complex conjugate template. More...
 
struct  TypedConjugate< std::complex< T > >
 

Typedefs

template<typename map_type >
using MapValueIterator = TupleViewIterator< 1, map_type >
 Iterator for a map to iterate over its values. More...
 
template<typename T >
using real_t = typename realTypeMap< T >::type
 Type mapper from T to real type of T. More...
 

Functions

template<typename T >
typed_conj (const T &val)
 Complex conjugate with type. This function returns the argument itself for real type, and returns its complex conjugate for complex type. More...
 
template<typename T >
inner_prod (const std::vector< T > &v1, const std::vector< T > &v2)
 Returns "mathematical" inner product of v1 and v2. More...
 
template<typename T >
real_t< T > norm (const std::vector< T > &vec)
 Returns Euclidean norm of given vector. More...
 
template<typename T1 , typename T2 >
void scalar_mul (T1 a, std::vector< T2 > &vec)
 Multiplies each element of vec by a. More...
 
template<typename T >
void normalize (std::vector< T > &vec)
 Normalizes given vector. More...
 
template<typename T >
real_t< T > l1_norm (const std::vector< T > &vec)
 Returns 1-norm of given vector. More...
 
template<typename ForwardIterator , typename T >
void schmidt_orth (std::vector< T > &uorth, ForwardIterator first, ForwardIterator last)
 Orthogonalizes vector uorth with respect to orthonormal vectors defined by given iterators. More...
 
template<typename T >
void initAsIdentity (std::vector< std::vector< T > > &a, size_t n)
 Initializes the given matrix a to an n by n identity matrix. More...
 
template<typename T >
void sort_eigenpairs (std::vector< real_t< T > > &eigenvalues, std::vector< std::vector< T > > &eigenvectors, bool sort_eigenvector, const std::function< bool(real_t< T >, real_t< T >)> predicate=std::less< real_t< T > >())
 Sorts eigenvalues and eigenvectors with respect to given predicate. More...
 
template<typename T >
constexpr int sig_decimal_digit ()
 Returns the significant decimal digits of type T. More...
 
template<typename T >
constexpr T minimum_effective_decimal ()
 
template<typename T >
sgn (T val)
 Return the sign of given value. More...
 
template<typename T >
std::string vectorToString (const std::vector< T > &vec, std::string delimiter=" ")
 Returns string representation of given vector. More...
 

Typedef Documentation

◆ MapValueIterator

template<typename map_type >
using lambda_lanczos::util::MapValueIterator = typedef TupleViewIterator<1, map_type>

Iterator for a map to iterate over its values.

◆ real_t

template<typename T >
using lambda_lanczos::util::real_t = typedef typename realTypeMap<T>::type

Type mapper from T to real type of T.

By default, real_t<T> returns T. However real_t<complex<T>> returns T. Usage example: This function returns a real number even if T is complex:

template <typename T>
inline real_t<T> norm(const std::vector<T>& vec);
real_t< T > norm(const std::vector< T > &vec)
Returns Euclidean norm of given vector.
Definition: lambda_lanczos_util.hpp:161
typename realTypeMap< T >::type real_t
Type mapper from T to real type of T.
Definition: lambda_lanczos_util.hpp:103

Function Documentation

◆ initAsIdentity()

template<typename T >
void lambda_lanczos::util::initAsIdentity ( std::vector< std::vector< T > > &  a,
size_t  n 
)

Initializes the given matrix a to an n by n identity matrix.

◆ inner_prod()

template<typename T >
T lambda_lanczos::util::inner_prod ( const std::vector< T > &  v1,
const std::vector< T > &  v2 
)
inline

Returns "mathematical" inner product of v1 and v2.

This function is needed because std::inner_product calculates transpose(v1)*v2 instead of dagger(v1)*v2 for complex type.

◆ l1_norm()

template<typename T >
real_t< T > lambda_lanczos::util::l1_norm ( const std::vector< T > &  vec)
inline

Returns 1-norm of given vector.

◆ minimum_effective_decimal()

template<typename T >
constexpr T lambda_lanczos::util::minimum_effective_decimal ( )
inlineconstexpr

◆ norm()

template<typename T >
real_t< T > lambda_lanczos::util::norm ( const std::vector< T > &  vec)
inline

Returns Euclidean norm of given vector.

◆ normalize()

template<typename T >
void lambda_lanczos::util::normalize ( std::vector< T > &  vec)
inline

Normalizes given vector.

◆ scalar_mul()

template<typename T1 , typename T2 >
void lambda_lanczos::util::scalar_mul ( T1  a,
std::vector< T2 > &  vec 
)
inline

Multiplies each element of vec by a.

◆ schmidt_orth()

template<typename ForwardIterator , typename T >
void lambda_lanczos::util::schmidt_orth ( std::vector< T > &  uorth,
ForwardIterator  first,
ForwardIterator  last 
)
inline

Orthogonalizes vector uorth with respect to orthonormal vectors defined by given iterators.

Vectors in u must be normalized, but uorth doesn't have to be.

◆ sgn()

template<typename T >
T lambda_lanczos::util::sgn ( val)

Return the sign of given value.

If 0 is given, this function returns +1.

◆ sig_decimal_digit()

template<typename T >
constexpr int lambda_lanczos::util::sig_decimal_digit ( )
inlineconstexpr

Returns the significant decimal digits of type T.

◆ sort_eigenpairs()

template<typename T >
void lambda_lanczos::util::sort_eigenpairs ( std::vector< real_t< T > > &  eigenvalues,
std::vector< std::vector< T > > &  eigenvectors,
bool  sort_eigenvector,
const std::function< bool(real_t< T >, real_t< T >)>  predicate = std::less<real_t<T>>() 
)
inline

Sorts eigenvalues and eigenvectors with respect to given predicate.

Note
This function changes the memory location of the eigenpairs.

◆ typed_conj()

template<typename T >
T lambda_lanczos::util::typed_conj ( const T &  val)
inline

Complex conjugate with type. This function returns the argument itself for real type, and returns its complex conjugate for complex type.

◆ vectorToString()

template<typename T >
std::string lambda_lanczos::util::vectorToString ( const std::vector< T > &  vec,
std::string  delimiter = " " 
)

Returns string representation of given vector.