xerus
a general purpose tensor library
xerus::misc Namespace Reference

Collection of classes and functions that provide elementary functionality that is not special to xerus as a tensor library. More...

Namespaces

 internal
 Namespace for function and classes designated only for internal use.
 
 performanceAnalysis
 This namespace contains all functions only used for the performance analysis, as well as the respective global variables.
 

Classes

class  generic_error
 The xerus exception class. More...
 
class  LimitExtractor
 Classes that can extract an estimate of the limit of a sequence. More...
 
class  LogHistogram
 A logarithmic histogram, i.e. the size of all buckets is given by a constant factor [x - x*base) More...
 
class  RichardsonExtrapolation
 Limit extraction using the richardson extrapolation. More...
 
class  ShanksTransformation
 Limit extraction using the shanks transformation aka Aitken process. More...
 

Enumerations

enum  FileFormat { FileFormat::BINARY, FileFormat::TSV }
 possible file formats for tensor storage More...
 

Functions

template<class T >
 __attribute__ ((const)) T difference(T _a
 
template<typename T >
void add (T *const __restrict _x, const T *const __restrict _y, const size_t _n) noexcept
 Adds _n entries of _y to the ones of _x. I.e. x += y. More...
 
template<typename T >
void add_scaled (T *const __restrict _x, const T _alpha, const T *const __restrict _y, const size_t _n) noexcept
 Adds _n entries of _y, scaled by _alpha to the ones of _x. I.e. x += alpha*y. More...
 
template<class T >
void apply_permutation (std::vector< T > &_vec, const std::vector< size_t > &_permutation)
 
template<class T , typename std::enable_if< std::is_floating_point< T >::value, bool >::type = true>
bool approx_equal (T _a, T _b, T _eps=4 *std::numeric_limits< T >::epsilon()) noexcept
 : Checks whether the relative difference between _a and _b (i.e. |a-b|/(|a|/2+|b|/2)) is smaller than _eps. More...
 
template<class T , typename std::enable_if<!std::is_floating_point< T >::value, bool >::type = true>
bool approx_equal (T _a, T _b)
 : Checks whether _a and _b are equal (for non floating point types). More...
 
template<typename T , typename std::enable_if< std::is_trivial< T >::value, int >::type = 0>
void copy (T *const __restrict _dest, const T *const __restrict _src, const size_t _n) noexcept
 Copys _n entries from _y to _x, where _y and _x must be disjunkt memory regions. More...
 
template<typename T , typename std::enable_if< std::is_trivial< T >::value, int >::type = 0>
void copy_inplace (T *const _x, const T *const _y, const size_t _n) noexcept
 Copys _n entries from _y to _x, allowing the accessed memry regions of _y and _x to overlap. More...
 
template<typename T >
void copy_scaled (T *const __restrict _x, const T _alpha, const T *const _y, const size_t _n) noexcept
 Copys _n entries from _y to _x, simulationously scaling each entry by the factor _alpha. I.e x = alpha*y. More...
 
template<class T , class Comparator >
std::vector< size_t > create_sort_permutation (const std::vector< T > &_vec, Comparator _comp)
 
std::string XERUS_warn_unused demangle_cxa (const std::string &_cxa)
 Demangles the function and class names created by gcc into a more readable format. More...
 
std::string exec (const std::string &_cmd)
 Execute a given command. More...
 
void exec (const std::string &_cmd, const std::string &_stdin)
 Execute a given command and pipe _stdin to its std input,. More...
 
std::vector< std::string > explode (const std::string &_string, const char _delim)
 : Explodes a string at positions indicated by _delim. More...
 
double find_root_bisection (const std::function< double(double)> &_f, double _min, double _max, double _epsilon=1e-14)
 
template<typename T >
from_string (const std::string &_s)
 : Creates an arbitary Object from string More...
 
template<>
XERUS_force_inline double from_string< double > (const std::string &_str)
 
template<>
XERUS_force_inline float from_string< float > (const std::string &_str)
 
template<>
XERUS_force_inline int from_string< int > (const std::string &_str)
 
template<>
XERUS_force_inline long from_string< long > (const std::string &_str)
 
template<>
XERUS_force_inline long double from_string< long double > (const std::string &_str)
 
template<>
XERUS_force_inline long long from_string< long long > (const std::string &_str)
 
template<>
XERUS_force_inline unsigned long from_string< unsigned long > (const std::string &_str)
 
template<>
XERUS_force_inline unsigned long long from_string< unsigned long long > (const std::string &_str)
 
std::string get_call_stack ()
 Returns a string representation of the current call-stack (excluding the function itself). More...
 
std::pair< uintptr_t, uintptr_t > get_range_of_section (void *_addr, std::string _name)
 Returns the address range of the elf-section names _name as part of the executable / so file that contained _addr. More...
 
template<class T >
constexpr bool hard_equal (const T _a, const T _b) noexcept
 : Checks for hard equality ( == operator) without compiler warnings. More...
 
template<class T >
constexpr bool hard_not_equal (const T _a, const T _b) noexcept
 : Checks for hard inequality ( != operator) without compiler warnings. More...
 
double integrate (const std::function< double(double)> &_f, double _a, double _b, double _eps=std::numeric_limits< double >::epsilon(), uint _minIter=4, uint _maxIter=6, uint _branchFactor=7, uint _maxRecursion=10, bool _relativeError=true)
 Performs a Romberg Integration (richardson extrapolation of regular riemannian sum) + adaptive refinement. More...
 
double integrate_segmented (const std::function< double(double)> &_f, double _a, double _b, double _segmentation, double _eps=1e-8, uint _minIter=4, uint _maxIter=6, uint _branchFactor=8, uint _maxRecursion=10)
 
template<class T >
void load_from_file (T &_obj, const std::string &_filename)
 
template<class T >
load_from_file (const std::string &_filename)
 
template<class T >
std::unique_ptr< T[]> make_unique_array (T *_ptr)
 
size_t mTime ()
 : Returns the time since epoche in milliseconds. More...
 
std::string XERUS_warn_unused normalize_pathname (const std::string &_name)
 Resolves 'folder/..' occurences in pathnames. More...
 
template<class... Tp>
std::ostream & operator<< (std::ostream &_out, const std::tuple< Tp... > &_tuple)
 Allow to pipe tuples to ostreams. More...
 
template<typename error_t , class T >
std::enable_if< std::is_base_of< generic_error, error_t >::value, error_t & >::type operator<< (error_t &o, const T &_info) noexcept
 The pipe operator allows to add everything that can be converted to string to the error_info and derived exceptions. More...
 
template<class first_t , class second_t >
std::ostream & operator<< (std::ostream &_out, const std::pair< first_t, second_t > &_pair)
 Allow to pipe std::pairs to ostreams. More...
 
template<typename error_t , class T >
std::enable_if< std::is_base_of< generic_error, error_t >::value, error_t & >::type operator<< (error_t &&o, const T &_info) noexcept
 The pipe operator allows to add everything that can be converted to string to the error_info and derived exceptions. More...
 
template<class item_t , class... rest_t>
std::ostream & operator<< (std::ostream &_out, const std::vector< item_t, rest_t... > &_container)
 Allow to pipe normal containers to ostreams. More...
 
template<class item_t , class... rest_t>
std::ostream & operator<< (std::ostream &_out, const std::set< item_t, rest_t... > &_container)
 Allow to pipe std::sets to ostreams. More...
 
template<class T , class U >
std::ostream & operator<< (std::ostream &_out, const std::map< T, U > &_set)
 Allow to pipe std::maps to ostreams. More...
 
template<class T >
constexpr T pow (const T &_base, const uint32 _exp) noexcept
 : Calculates _base^_exp by binary exponentiation More...
 
template<class T >
constexpr T pow (const T &_base, const uint64 _exp) noexcept
 : Calculates _base^_exp by binary exponentiation More...
 
template<class T >
constexpr T pow (const T &_base, const int64 _exp) noexcept
 : Calculates _base^_exp by binary exponentiation More...
 
template<class T >
constexpr T pow (const T &_base, const int32 _exp) noexcept
 : Calculates _base^_exp by binary exponentiation More...
 
thread_local std::mt19937_64 randomEngine (std::random_device{}())
 
template<class T >
XERUS_force_inline void read_from_stream (std::istream &_stream, T &_obj, const FileFormat _format)
 
template<class T >
XERUS_force_inlineread_from_stream (std::istream &_stream, const FileFormat _format)
 
std::string XERUS_warn_unused reduce (const std::string &_string, const std::string &whitespace=" \\", const std::string &fill=" ")
 : Removes all leading and trailing whitespaces from _string, and reduces all double whitespaces to one. More...
 
void replace (std::string &_string, const std::string &_search, const std::string &_replace)
 : Replaces all occurences of _search in _string by _replace. More...
 
template<class T >
void save_to_file (const T &_obj, const std::string &_filename, const FileFormat _format=FileFormat::BINARY)
 
template<typename T >
void scale (T *const __restrict _x, const T _alpha, const size_t _n) noexcept
 Scales _n entries of _x by the factor _alpha. I.e. x = alpha*x. More...
 
template<typename T , typename std::enable_if< std::is_trivial< T >::value, int >::type = 0>
void set_zero (T *const __restrict _x, const size_t _n) noexcept
 Sets all entries equal to zero. More...
 
template<class T >
constexpr int sgn (const T _value) noexcept
 : Calculates the signum (-1, 0, 1) of a given value. More...
 
template<class KeyType , class DataType , class Comparator >
void simultaneous_sort (std::vector< KeyType > &_keyVector, std::vector< DataType > &_dataVector, Comparator _comp)
 
template<class T >
constexpr T sqr (const T &_a) noexcept
 : Calculates _a*_a. More...
 
template<class T , typename std::enable_if< std::is_arithmetic< T >::value, bool >::type = true>
void stream_reader (std::istream &_stream, T &_obj, const FileFormat _format)
 
template<class T >
void stream_reader (std::istream &_stream, std::vector< T > &_obj, const FileFormat _format)
 
void stream_reader (std::istream &_stream, TensorNetwork &_obj, const FileFormat _format)
 Restores the TensorNetwork from a stream of data. More...
 
template<bool isOperator>
void stream_reader (std::istream &_stream, TTNetwork< isOperator > &_obj, const misc::FileFormat _format)
 Restores the TTNetwork from a stream of data. More...
 
void stream_reader (std::istream &_stream, Tensor &_obj, const FileFormat _format)
 tries to restore the tensor from a stream of data. More...
 
template void stream_reader (std::istream &_stream, TTNetwork< true > &_obj, const misc::FileFormat _format)
 
template void stream_reader (std::istream &_stream, TTNetwork< false > &_obj, const misc::FileFormat _format)
 
template<class T , typename std::enable_if< std::is_arithmetic< T >::value, bool >::type = true>
void stream_writer (std::ostream &_stream, const T &_value, FileFormat _format)
 
template<class T >
void stream_writer (std::ostream &_stream, const std::vector< T > &_value, FileFormat _format)
 
void stream_writer (std::ostream &_stream, const TensorNetwork &_obj, const FileFormat _format)
 Pipes all information necessary to restore the current TensorNetwork into _stream. More...
 
template<bool isOperator>
void stream_writer (std::ostream &_stream, const TTNetwork< isOperator > &_obj, misc::FileFormat _format)
 Pipes all information necessary to restore the current TensorNetwork into _stream. More...
 
void stream_writer (std::ostream &_stream, const Tensor &_obj, const FileFormat _format)
 pipes all information necessary to restore the current tensor into _stream. More...
 
template void stream_writer (std::ostream &_stream, const TTNetwork< true > &_obj, misc::FileFormat _format)
 
template void stream_writer (std::ostream &_stream, const TTNetwork< false > &_obj, misc::FileFormat _format)
 
static XERUS_force_inline std::string to_string (const bool obj)
 
static XERUS_force_inline std::string to_string (const std::string &obj)
 
static XERUS_force_inline std::string to_string (const char *const obj)
 
template<typename T >
std::string to_string (const T &obj)
 : Converts any object (which has no specialized function for it) to string. More...
 
template<typename T >
std::string to_string (const T &obj, const long _precision)
 : Converts an arbitary Object to string with fixed precision More...
 
std::string XERUS_warn_unused trim (const std::string &_string, const std::string &whitespace=" \\")
 : Removes all leading and trailing whitespaces from _string. More...
 
size_t uTime ()
 : Returns the time since epoche in microseconds. More...
 
template<class T >
XERUS_force_inline void write_to_stream (std::ostream &_stream, const T &_value, FileFormat _format)
 
 XERUS_GENERATE_HAS_MEMBER (count) template< template< class
 : Counts how often an element is contained in an arbitary container More...
 

Variables

_b
 
thread_local std::normal_distribution< double > defaultNormalDistribution
 
thread_local std::mt19937_64 randomEngine
 

Detailed Description

Collection of classes and functions that provide elementary functionality that is not special to xerus as a tensor library.

Enumeration Type Documentation

◆ FileFormat

possible file formats for tensor storage

BINARY: binary output, exact storage TSV: tab-separated-value lists

Enumerator
BINARY 
TSV 

Definition at line 43 of file fileIO.h.

Function Documentation

◆ __attribute__()

template<class T >
xerus::misc::__attribute__ ( (const)  )

◆ add()

template<typename T >
void xerus::misc::add ( T *const __restrict  _x,
const T *const __restrict  _y,
const size_t  _n 
)
inlinenoexcept

Adds _n entries of _y to the ones of _x. I.e. x += y.

Definition at line 96 of file basicArraySupport.h.

◆ add_scaled()

template<typename T >
void xerus::misc::add_scaled ( T *const __restrict  _x,
const T  _alpha,
const T *const __restrict  _y,
const size_t  _n 
)
inlinenoexcept

Adds _n entries of _y, scaled by _alpha to the ones of _x. I.e. x += alpha*y.

Definition at line 107 of file basicArraySupport.h.

◆ apply_permutation()

template<class T >
void xerus::misc::apply_permutation ( std::vector< T > &  _vec,
const std::vector< size_t > &  _permutation 
)

Definition at line 41 of file sort.h.

◆ approx_equal() [1/2]

template<class T , typename std::enable_if< std::is_floating_point< T >::value, bool >::type = true>
bool xerus::misc::approx_equal ( _a,
_b,
_eps = 4*std::numeric_limits<T>::epsilon() 
)
noexcept

: Checks whether the relative difference between _a and _b (i.e. |a-b|/(|a|/2+|b|/2)) is smaller than _eps.

Definition at line 91 of file math.h.

◆ approx_equal() [2/2]

template<class T , typename std::enable_if<!std::is_floating_point< T >::value, bool >::type = true>
bool xerus::misc::approx_equal ( _a,
_b 
)

: Checks whether _a and _b are equal (for non floating point types).

Definition at line 98 of file math.h.

◆ copy()

template<typename T , typename std::enable_if< std::is_trivial< T >::value, int >::type = 0>
void xerus::misc::copy ( T *const __restrict  _dest,
const T *const __restrict  _src,
const size_t  _n 
)
inlinenoexcept

Copys _n entries from _y to _x, where _y and _x must be disjunkt memory regions.

For trivial copyable types this is only a slim wrapper for memcpy.

Definition at line 55 of file basicArraySupport.h.

◆ copy_inplace()

template<typename T , typename std::enable_if< std::is_trivial< T >::value, int >::type = 0>
void xerus::misc::copy_inplace ( T *const  _x,
const T *const  _y,
const size_t  _n 
)
inlinenoexcept

Copys _n entries from _y to _x, allowing the accessed memry regions of _y and _x to overlap.

For trivial copyable types this is only a slim wrapper for memmove.

Definition at line 65 of file basicArraySupport.h.

◆ copy_scaled()

template<typename T >
void xerus::misc::copy_scaled ( T *const __restrict  _x,
const T  _alpha,
const T *const  _y,
const size_t  _n 
)
inlinenoexcept

Copys _n entries from _y to _x, simulationously scaling each entry by the factor _alpha. I.e x = alpha*y.

Definition at line 74 of file basicArraySupport.h.

◆ create_sort_permutation()

template<class T , class Comparator >
std::vector<size_t> xerus::misc::create_sort_permutation ( const std::vector< T > &  _vec,
Comparator  _comp 
)

Definition at line 33 of file sort.h.

◆ demangle_cxa()

std::string xerus::misc::demangle_cxa ( const std::string &  _cxa)

Demangles the function and class names created by gcc into a more readable format.

Definition at line 33 of file stringUtilities.cpp.

◆ exec() [1/2]

std::string xerus::misc::exec ( const std::string &  _cmd)

Execute a given command.

Parameters
_cmdthe command to execute
Returns
the cout return of the command.

Definition at line 31 of file missingFunctions.cpp.

◆ exec() [2/2]

void xerus::misc::exec ( const std::string &  _cmd,
const std::string &  _stdin 
)

Execute a given command and pipe _stdin to its std input,.

Parameters
_cmdthe command to execute
_stdinthe input for the program

Definition at line 45 of file missingFunctions.cpp.

◆ explode()

std::vector< std::string > xerus::misc::explode ( const std::string &  _string,
const char  _delim 
)

: Explodes a string at positions indicated by _delim.

Definition at line 64 of file stringUtilities.cpp.

◆ find_root_bisection()

double xerus::misc::find_root_bisection ( const std::function< double(double)> &  _f,
double  _min,
double  _max,
double  _epsilon = 1e-14 
)

Definition at line 109 of file simpleNumerics.cpp.

◆ from_string()

template<typename T >
T xerus::misc::from_string ( const std::string &  _s)

: Creates an arbitary Object from string

Definition at line 93 of file stringFromTo.h.

◆ from_string< double >()

template<>
XERUS_force_inline double xerus::misc::from_string< double > ( const std::string &  _str)

Definition at line 131 of file stringFromTo.h.

◆ from_string< float >()

template<>
XERUS_force_inline float xerus::misc::from_string< float > ( const std::string &  _str)

Definition at line 126 of file stringFromTo.h.

◆ from_string< int >()

template<>
XERUS_force_inline int xerus::misc::from_string< int > ( const std::string &  _str)

Definition at line 101 of file stringFromTo.h.

◆ from_string< long >()

template<>
XERUS_force_inline long xerus::misc::from_string< long > ( const std::string &  _str)

Definition at line 106 of file stringFromTo.h.

◆ from_string< long double >()

template<>
XERUS_force_inline long double xerus::misc::from_string< long double > ( const std::string &  _str)

Definition at line 136 of file stringFromTo.h.

◆ from_string< long long >()

template<>
XERUS_force_inline long long xerus::misc::from_string< long long > ( const std::string &  _str)

Definition at line 111 of file stringFromTo.h.

◆ from_string< unsigned long >()

template<>
XERUS_force_inline unsigned long xerus::misc::from_string< unsigned long > ( const std::string &  _str)

Definition at line 116 of file stringFromTo.h.

◆ from_string< unsigned long long >()

template<>
XERUS_force_inline unsigned long long xerus::misc::from_string< unsigned long long > ( const std::string &  _str)

Definition at line 121 of file stringFromTo.h.

◆ get_call_stack()

std::string xerus::misc::get_call_stack ( )

Returns a string representation of the current call-stack (excluding the function itself).

Per default this uses the binutils library to get the following information: [address .section] filename:line (function) if all of these are available.

Definition at line 166 of file callStack.cpp.

◆ get_range_of_section()

std::pair< uintptr_t, uintptr_t > xerus::misc::get_range_of_section ( void *  _addr,
std::string  _name 
)

Returns the address range of the elf-section names _name as part of the executable / so file that contained _addr.

Definition at line 186 of file callStack.cpp.

◆ hard_equal()

template<class T >
constexpr bool xerus::misc::hard_equal ( const T  _a,
const T  _b 
)
noexcept

: Checks for hard equality ( == operator) without compiler warnings.

Definition at line 105 of file math.h.

◆ hard_not_equal()

template<class T >
constexpr bool xerus::misc::hard_not_equal ( const T  _a,
const T  _b 
)
noexcept

: Checks for hard inequality ( != operator) without compiler warnings.

Definition at line 115 of file math.h.

◆ integrate()

double xerus::misc::integrate ( const std::function< double(double)> &  _f,
double  _a,
double  _b,
double  _eps = std::numeric_limits<double>::epsilon(),
uint  _minIter = 4,
uint  _maxIter = 6,
uint  _branchFactor = 7,
uint  _maxRecursion = 10,
bool  _relativeError = true 
)

Performs a Romberg Integration (richardson extrapolation of regular riemannian sum) + adaptive refinement.

Definition at line 37 of file simpleNumerics.cpp.

◆ integrate_segmented()

double xerus::misc::integrate_segmented ( const std::function< double(double)> &  _f,
double  _a,
double  _b,
double  _segmentation,
double  _eps = 1e-8,
uint  _minIter = 4,
uint  _maxIter = 6,
uint  _branchFactor = 8,
uint  _maxRecursion = 10 
)

Definition at line 98 of file simpleNumerics.cpp.

◆ load_from_file() [1/2]

template<class T >
void xerus::misc::load_from_file ( T &  _obj,
const std::string &  _filename 
)

Definition at line 122 of file fileIO.h.

◆ load_from_file() [2/2]

template<class T >
T xerus::misc::load_from_file ( const std::string &  _filename)

Definition at line 160 of file fileIO.h.

◆ make_unique_array()

template<class T >
std::unique_ptr<T[]> xerus::misc::make_unique_array ( T *  _ptr)

Definition at line 36 of file basicArraySupport.h.

◆ mTime()

size_t xerus::misc::mTime ( )

: Returns the time since epoche in milliseconds.

Definition at line 35 of file timeMeasure.cpp.

◆ normalize_pathname()

std::string xerus::misc::normalize_pathname ( const std::string &  _name)

Resolves 'folder/..' occurences in pathnames.

Definition at line 44 of file stringUtilities.cpp.

◆ operator<<() [1/7]

template<class... Tp>
std::ostream& xerus::misc::operator<< ( std::ostream &  _out,
const std::tuple< Tp... > &  _tuple 
)

Allow to pipe tuples to ostreams.

Definition at line 50 of file containerOutput.h.

◆ operator<<() [2/7]

template<typename error_t , class T >
std::enable_if<std::is_base_of<generic_error, error_t>::value, error_t&>::type xerus::misc::operator<< ( error_t &  o,
const T &  _info 
)
noexcept

The pipe operator allows to add everything that can be converted to string to the error_info and derived exceptions.

Definition at line 54 of file exceptions.h.

◆ operator<<() [3/7]

template<class first_t , class second_t >
std::ostream& xerus::misc::operator<< ( std::ostream &  _out,
const std::pair< first_t, second_t > &  _pair 
)

Allow to pipe std::pairs to ostreams.

Definition at line 60 of file containerOutput.h.

◆ operator<<() [4/7]

template<typename error_t , class T >
std::enable_if<std::is_base_of<generic_error, error_t>::value, error_t&>::type xerus::misc::operator<< ( error_t &&  o,
const T &  _info 
)
noexcept

The pipe operator allows to add everything that can be converted to string to the error_info and derived exceptions.

Definition at line 62 of file exceptions.h.

◆ operator<<() [5/7]

template<class item_t , class... rest_t>
std::ostream& xerus::misc::operator<< ( std::ostream &  _out,
const std::vector< item_t, rest_t... > &  _container 
)

Allow to pipe normal containers to ostreams.

Definition at line 68 of file containerOutput.h.

◆ operator<<() [6/7]

template<class item_t , class... rest_t>
std::ostream& xerus::misc::operator<< ( std::ostream &  _out,
const std::set< item_t, rest_t... > &  _container 
)

Allow to pipe std::sets to ostreams.

Definition at line 79 of file containerOutput.h.

◆ operator<<() [7/7]

template<class T , class U >
std::ostream& xerus::misc::operator<< ( std::ostream &  _out,
const std::map< T, U > &  _set 
)

Allow to pipe std::maps to ostreams.

Definition at line 90 of file containerOutput.h.

◆ pow() [1/4]

template<class T >
constexpr T xerus::misc::pow ( const T &  _base,
const uint32  _exp 
)
noexcept

: Calculates _base^_exp by binary exponentiation

Definition at line 50 of file math.h.

◆ pow() [2/4]

template<class T >
constexpr T xerus::misc::pow ( const T &  _base,
const uint64  _exp 
)
noexcept

: Calculates _base^_exp by binary exponentiation

Definition at line 56 of file math.h.

◆ pow() [3/4]

template<class T >
constexpr T xerus::misc::pow ( const T &  _base,
const int64  _exp 
)
noexcept

: Calculates _base^_exp by binary exponentiation

Definition at line 63 of file math.h.

◆ pow() [4/4]

template<class T >
constexpr T xerus::misc::pow ( const T &  _base,
const int32  _exp 
)
noexcept

: Calculates _base^_exp by binary exponentiation

Definition at line 77 of file math.h.

◆ randomEngine()

thread_local std::mt19937_64 xerus::misc::randomEngine ( std::random_device{}  ())

◆ read_from_stream() [1/2]

template<class T >
XERUS_force_inline void xerus::misc::read_from_stream ( std::istream &  _stream,
T &  _obj,
const FileFormat  _format 
)

Definition at line 71 of file fileIO.h.

◆ read_from_stream() [2/2]

template<class T >
XERUS_force_inline T xerus::misc::read_from_stream ( std::istream &  _stream,
const FileFormat  _format 
)

Definition at line 76 of file fileIO.h.

◆ reduce()

std::string xerus::misc::reduce ( const std::string &  _string,
const std::string &  whitespace = " \t\n\r\v",
const std::string &  fill = " " 
)

: Removes all leading and trailing whitespaces from _string, and reduces all double whitespaces to one.

Definition at line 93 of file stringUtilities.cpp.

◆ replace()

void xerus::misc::replace ( std::string &  _string,
const std::string &  _search,
const std::string &  _replace 
)

: Replaces all occurences of _search in _string by _replace.

Definition at line 76 of file stringUtilities.cpp.

◆ save_to_file()

template<class T >
void xerus::misc::save_to_file ( const T &  _obj,
const std::string &  _filename,
const FileFormat  _format = FileFormat::BINARY 
)

Definition at line 103 of file fileIO.h.

◆ scale()

template<typename T >
void xerus::misc::scale ( T *const __restrict  _x,
const T  _alpha,
const size_t  _n 
)
inlinenoexcept

Scales _n entries of _x by the factor _alpha. I.e. x = alpha*x.

Definition at line 85 of file basicArraySupport.h.

◆ set_zero()

template<typename T , typename std::enable_if< std::is_trivial< T >::value, int >::type = 0>
void xerus::misc::set_zero ( T *const __restrict  _x,
const size_t  _n 
)
inlinenoexcept

Sets all entries equal to zero.

This is done directly by memset and therefore requires the type to be trivial.

Definition at line 45 of file basicArraySupport.h.

◆ sgn()

template<class T >
constexpr int xerus::misc::sgn ( const T  _value)
noexcept

: Calculates the signum (-1, 0, 1) of a given value.

Definition at line 36 of file math.h.

◆ simultaneous_sort()

template<class KeyType , class DataType , class Comparator >
void xerus::misc::simultaneous_sort ( std::vector< KeyType > &  _keyVector,
std::vector< DataType > &  _dataVector,
Comparator  _comp 
)

Definition at line 52 of file sort.h.

◆ sqr()

template<class T >
constexpr T xerus::misc::sqr ( const T &  _a)
noexcept

: Calculates _a*_a.

Definition at line 43 of file math.h.

◆ stream_reader() [1/7]

template<class T , typename std::enable_if< std::is_arithmetic< T >::value, bool >::type = true>
void xerus::misc::stream_reader ( std::istream &  _stream,
T &  _obj,
const FileFormat  _format 
)

Definition at line 83 of file fileIO.h.

◆ stream_reader() [2/7]

template<class T >
void xerus::misc::stream_reader ( std::istream &  _stream,
std::vector< T > &  _obj,
const FileFormat  _format 
)

Definition at line 92 of file fileIO.h.

◆ stream_reader() [3/7]

void xerus::misc::stream_reader ( std::istream &  _stream,
TensorNetwork _obj,
const FileFormat  _format 
)

Restores the TensorNetwork from a stream of data.

Definition at line 1469 of file tensorNetwork.cpp.

◆ stream_reader() [4/7]

template<bool isOperator>
void xerus::misc::stream_reader ( std::istream &  _stream,
TTNetwork< isOperator > &  _obj,
const misc::FileFormat  _format 
)

Restores the TTNetwork from a stream of data.

Definition at line 1475 of file ttNetwork.cpp.

◆ stream_reader() [5/7]

void xerus::misc::stream_reader ( std::istream &  _stream,
Tensor _obj,
const FileFormat  _format 
)

tries to restore the tensor from a stream of data.

Definition at line 1807 of file tensor.cpp.

◆ stream_reader() [6/7]

template void xerus::misc::stream_reader ( std::istream &  _stream,
TTNetwork< true > &  _obj,
const misc::FileFormat  _format 
)

◆ stream_reader() [7/7]

template void xerus::misc::stream_reader ( std::istream &  _stream,
TTNetwork< false > &  _obj,
const misc::FileFormat  _format 
)

◆ stream_writer() [1/7]

template<class T , typename std::enable_if< std::is_arithmetic< T >::value, bool >::type = true>
void xerus::misc::stream_writer ( std::ostream &  _stream,
const T &  _value,
FileFormat  _format 
)

Definition at line 52 of file fileIO.h.

◆ stream_writer() [2/7]

template<class T >
void xerus::misc::stream_writer ( std::ostream &  _stream,
const std::vector< T > &  _value,
FileFormat  _format 
)

Definition at line 61 of file fileIO.h.

◆ stream_writer() [3/7]

void xerus::misc::stream_writer ( std::ostream &  _stream,
const TensorNetwork _obj,
const FileFormat  _format 
)

Pipes all information necessary to restore the current TensorNetwork into _stream.

Note
that this excludes header information

Definition at line 1429 of file tensorNetwork.cpp.

◆ stream_writer() [4/7]

template<bool isOperator>
void xerus::misc::stream_writer ( std::ostream &  _stream,
const TTNetwork< isOperator > &  _obj,
misc::FileFormat  _format 
)

Pipes all information necessary to restore the current TensorNetwork into _stream.

Note
that this excludes header information

Definition at line 1455 of file ttNetwork.cpp.

◆ stream_writer() [5/7]

void xerus::misc::stream_writer ( std::ostream &  _stream,
const Tensor _obj,
const FileFormat  _format 
)

pipes all information necessary to restore the current tensor into _stream.

Note
that this excludes header information

Definition at line 1781 of file tensor.cpp.

◆ stream_writer() [6/7]

template void xerus::misc::stream_writer ( std::ostream &  _stream,
const TTNetwork< true > &  _obj,
misc::FileFormat  _format 
)

◆ stream_writer() [7/7]

template void xerus::misc::stream_writer ( std::ostream &  _stream,
const TTNetwork< false > &  _obj,
misc::FileFormat  _format 
)

◆ to_string() [1/5]

static XERUS_force_inline std::string xerus::misc::to_string ( const bool  obj)
static

Definition at line 41 of file stringFromTo.h.

◆ to_string() [2/5]

static XERUS_force_inline std::string xerus::misc::to_string ( const std::string &  obj)
static

Definition at line 45 of file stringFromTo.h.

◆ to_string() [3/5]

static XERUS_force_inline std::string xerus::misc::to_string ( const char *const  obj)
static

Definition at line 49 of file stringFromTo.h.

◆ to_string() [4/5]

template<typename T >
std::string xerus::misc::to_string ( const T &  obj)

: Converts any object (which has no specialized function for it) to string.

Definition at line 69 of file stringFromTo.h.

◆ to_string() [5/5]

template<typename T >
std::string xerus::misc::to_string ( const T &  obj,
const long  _precision 
)

: Converts an arbitary Object to string with fixed precision

Definition at line 80 of file stringFromTo.h.

◆ trim()

std::string xerus::misc::trim ( const std::string &  _string,
const std::string &  whitespace = " \t\n\r\v" 
)

: Removes all leading and trailing whitespaces from _string.

Definition at line 84 of file stringUtilities.cpp.

◆ uTime()

size_t xerus::misc::uTime ( )

: Returns the time since epoche in microseconds.

Definition at line 30 of file timeMeasure.cpp.

◆ write_to_stream()

template<class T >
XERUS_force_inline void xerus::misc::write_to_stream ( std::ostream &  _stream,
const T &  _value,
FileFormat  _format 
)

Definition at line 47 of file fileIO.h.

◆ XERUS_GENERATE_HAS_MEMBER()

xerus::misc::XERUS_GENERATE_HAS_MEMBER ( count  )

: Counts how often an element is contained in an arbitary container

Variable Documentation

◆ _b

T xerus::misc::_b

Definition at line 45 of file simpleNumerics.h.

◆ defaultNormalDistribution

thread_local std::normal_distribution< double > xerus::misc::defaultNormalDistribution

Definition at line 30 of file random.cpp.

◆ randomEngine

thread_local std::mt19937_64 xerus::misc::randomEngine