35#include <itpp/itexports.h>
46inline double sqr(
double x) {
return (x * x); }
48inline double sqr(
const std::complex<double>& x)
50 return (x.real() * x.real() + x.imag() * x.imag());
57ITPP_EXPORT vec
sqr(
const cvec &x);
59ITPP_EXPORT mat
sqr(
const cmat &x);
73ITPP_EXPORT vec
abs(
const cvec &x);
75ITPP_EXPORT mat
abs(
const cmat &x);
81inline double sign(
double x)
83 return (x == 0.0 ? 0.0 : (x < 0.0 ? -1.0 : 1.0));
91inline double sgn(
double x) {
return sign(x); }
100 return (x == 0 ? 0 : (x < 0 ? -1 : 1));
117 return (x == 0.0 ? 0 : (x < 0.0 ? -1 : 1));
131ITPP_EXPORT
double gamma(
double x);
133ITPP_EXPORT vec
gamma(
const vec &x);
135ITPP_EXPORT mat
gamma(
const mat &x);
141inline double rem(
double x,
double y) {
return fmod(x, y); }
143inline vec
rem(
const vec &x,
double y)
148inline vec
rem(
double x,
const vec &y)
153inline mat
rem(
const mat &x,
double y)
158inline mat
rem(
double x,
const mat &y)
166inline int mod(
int k,
int n)
168 return (n == 0) ? k : (k - n *
floor_i(
static_cast<double>(k) / n));
175ITPP_EXPORT
double fact(
int index);
181ITPP_EXPORT
double binom(
int n,
int k);
184ITPP_EXPORT
int binom_i(
int n,
int k);
187ITPP_EXPORT
double log_binom(
int n,
int k);
199ITPP_EXPORT
int gcd(
int a,
int b);
205ITPP_EXPORT vec
real(
const cvec &x);
207ITPP_EXPORT mat
real(
const cmat &x);
209ITPP_EXPORT vec
imag(
const cvec &x);
211ITPP_EXPORT mat
imag(
const cmat &x);
214ITPP_EXPORT vec
arg(
const cvec &x);
216ITPP_EXPORT mat
arg(
const cmat &x);
237ITPP_EXPORT cvec
conj(
const cvec &x);
240ITPP_EXPORT cmat
conj(
const cmat &x);
Definitions of converters between different vector and matrix types.
double gamma(double x)
Deprecated gamma function - please use tgamma() instead.
int sgn_i(int x)
Signum function.
double sign(double x)
Signum function.
double binom(int n, int k)
Compute the binomial coefficient "n over k".
double sgn(double x)
Signum function.
int mod(int k, int n)
Calculates the modulus, i.e. the signed reminder after division.
double rem(double x, double y)
The reminder of the division x/y.
double fact(int index)
Calculates factorial coefficient for index <= 170.
vec imag(const cvec &data)
Imaginary part of complex values.
vec angle(const cvec &x)
Angle.
vec arg(const cvec &data)
Argument (angle)
Vec< T > apply_function(T(*f)(T), const Vec< T > &v)
Help function to call for a function: Vec<T> function(Vec<T>)
int binom_i(int n, int k)
Compute the binomial coefficient "n over k".
vec real(const cvec &data)
Real part of complex values.
vec sqr(const cvec &data)
Absolute square of elements.
int gcd(int a, int b)
Compute the greatest common divisor (GCD) g of the elements a and b.
int sign_i(int x)
Signum function.
cvec conj(const cvec &x)
Conjugate of complex value.
vec sqrt(const vec &x)
Square root of the elements.
double log_binom(int n, int k)
Compute the base 10 logarithm of the binomial coefficient "n over k".
Help functions to make functions with vec and mat as arguments.
int floor_i(double x)
The nearest smaller integer.
bin abs(const bin &inbin)
absolute value of bin
int abs(const itpp::bin &inbin)
absolute value of bin