(9)

util.h File Reference

File that contains various utility functions. More...

Namespaces

 OFELI
 A namespace to group all library classes, functions, ...
 

Functions

int Sgn (real_t a)
 Return sign of a: -1 or 1.
 
real_t Sgn (real_t a, real_t b)
 Return |a| if b>0, -|a| if not.
 
real_t Abs2 (complex_t a)
 Return square of modulus of complex number a
 
real_t Abs2 (real_t a)
 Return square of real number a
 
real_t Abs (real_t a)
 Return absolute value of a
 
real_t Abs (complex_t a)
 Return modulus of complex number a
 
real_t Abs (const Point< real_t > &p)
 Return norm of vector a
 
real_t Conjg (real_t a)
 Return complex conjugate of real number a
 
complex_t Conjg (complex_t a)
 Return complex conjugate of complex number a
 
string out_complex (complex_t z)
 Return string to conveniently display a complex number. More...
 
string out_complex (real_t x, real_t y)
 Return string to conviently display a complex number. More...
 
real_t Max (real_t a, real_t b, real_t c)
 Return maximum value of real numbers a, b and c
 
int Kronecker (int i, int j)
 Return Kronecker delta of i and j.
 
template<class T_ >
const T_ & Max (const T_ &a, const T_ &b)
 Return maximum value of elements a and b
 
template<class T_ >
const T_ & Min (const T_ &a, const T_ &b)
 Return minimum value of elements a and b
 
int Max (int a, int b, int c)
 Return maximum value of integer numbers a, b and c
 
real_t Min (real_t a, real_t b, real_t c)
 Return minimum value of real numbers a, b and c
 
int Min (int a, int b, int c)
 Return minimum value of integer numbers a, b and c
 
real_t Max (real_t a, real_t b, real_t c, real_t d)
 Return maximum value of integer numbers a, b, c and d
 
int Max (int a, int b, int c, int d)
 Return maximum value of integer numbers a, b, c and d
 
real_t Min (real_t a, real_t b, real_t c, real_t d)
 Return minimum value of real numbers a, b, c and d
 
int Min (int a, int b, int c, int d)
 Return minimum value of integer numbers a, b, c and d
 
real_t Arg (complex_t x)
 Return argument of complex number x
 
complex_t Log (complex_t x)
 Return principal determination of logarithm of complex number x
 
template<class T_ >
T_ Sqr (T_ x)
 Return square of value x
 
template<class T_ >
void Scale (T_ a, const vector< T_ > &x, vector< T_ > &y)
 Mutiply vector x by a and save result in vector y More...
 
template<class T_ >
void Scale (T_ a, const Vect< T_ > &x, Vect< T_ > &y)
 Mutiply vector x by a and save result in vector y More...
 
template<class T_ >
void Scale (T_ a, vector< T_ > &x)
 Mutiply vector x by a More...
 
template<class T_ >
void Xpy (size_t n, T_ *x, T_ *y)
 Add array x to y
 
template<class T_ >
void Xpy (const vector< T_ > &x, vector< T_ > &y)
 Add vector x to y More...
 
template<class T_ >
void Axpy (size_t n, T_ a, T_ *x, T_ *y)
 Multiply array x by a and add result to y More...
 
template<class T_ >
void Axpy (T_ a, const vector< T_ > &x, vector< T_ > &y)
 Multiply vector x by a and add result to y More...
 
template<class T_ >
void Copy (size_t n, T_ *x, T_ *y)
 Copy array x to y n is the arrays size.
 
real_t Error2 (const vector< real_t > &x, const vector< real_t > &y)
 Return absolute L2 error between vectors x and y
 
real_t RError2 (const vector< real_t > &x, const vector< real_t > &y)
 Return absolute L2 error between vectors x and y
 
real_t ErrorMax (const vector< real_t > &x, const vector< real_t > &y)
 Return absolute Max. error between vectors x and y
 
real_t RErrorMax (const vector< real_t > &x, const vector< real_t > &y)
 Return relative Max. error between vectors x and y
 
template<class T_ >
T_ Dot (size_t n, T_ *x, T_ *y)
 Return dot product of arrays x and y More...
 
real_t Dot (const vector< real_t > &x, const vector< real_t > &y)
 Return dot product of vectors x and y. More...
 
real_t operator* (const vector< real_t > &x, const vector< real_t > &y)
 Operator * (Dot product of 2 vector instances) More...
 
template<class T_ >
T_ Dot (const Point< T_ > &x, const Point< T_ > &y)
 Return dot product of x and y
 
real_t exprep (real_t x)
 Compute the exponential function with avoiding over and underflows.
 
template<class T_ >
void Assign (vector< T_ > &v, const T_ &a)
 Assign the value a to all entries of a vector v
 
template<class T_ >
void clear (vector< T_ > &v)
 Assign 0 to all entries of a vector. More...
 
template<class T_ >
void clear (Vect< T_ > &v)
 Assign 0 to all entries of a vector. More...
 
real_t Nrm2 (size_t n, real_t *x)
 Return 2-norm of array x More...
 
real_t Nrm2 (const vector< real_t > &x)
 Return 2-norm of vector x
 
template<class T_ >
real_t Nrm2 (const Point< T_ > &a)
 Return 2-norm of a
 
bool Equal (real_t x, real_t y, real_t toler=OFELI_EPSMCH)
 Function to return true if numbers x and y are close up to a given tolerance toler More...
 
char itoc (int i)
 Function to convert an integer to a character.
 
template<class T_ >
std::string toString (const T_ x)
 Function to convert any value to a string.
 
template<class T_ >
T_ stringTo (const std::string &s)
 Function to convert a string to a template type parameter.
 

Detailed Description

File that contains various utility functions.