Go to the documentation of this file.
35 #include <itpp/itexports.h>
46 inline double sqr(
double x) {
return (x * x); }
48 inline double sqr(
const std::complex<double>& x)
50 return (x.real() * x.real() + x.imag() * x.imag());
53 inline vec
sqr(
const vec &x) {
return apply_function<double>(
sqr, x); }
55 inline mat
sqr(
const mat &x) {
return apply_function<double>(
sqr, x); }
57 ITPP_EXPORT vec
sqr(
const cvec &x);
59 ITPP_EXPORT mat
sqr(
const cmat &x);
65 inline vec
abs(
const vec &x) {
return apply_function<double>(std::fabs, x); }
67 inline mat
abs(
const mat &x) {
return apply_function<double>(std::fabs, x); }
69 inline ivec
abs(
const ivec &x) {
return apply_function<int>(
std::abs, x); }
71 inline imat
abs(
const imat &x) {
return apply_function<int>(
std::abs, x); }
73 ITPP_EXPORT vec
abs(
const cvec &x);
75 ITPP_EXPORT mat
abs(
const cmat &x);
81 inline double sign(
double x)
83 return (x == 0.0 ? 0.0 : (x < 0.0 ? -1.0 : 1.0));
86 inline vec
sign(
const vec &x) {
return apply_function<double>(
sign, x); }
88 inline mat
sign(
const mat &x) {
return apply_function<double>(
sign, x); }
91 inline double sgn(
double x) {
return sign(x); }
93 inline vec
sgn(
const vec &x) {
return apply_function<double>(
sign, x); }
95 inline mat
sgn(
const mat &x) {
return apply_function<double>(
sign, x); }
100 return (x == 0 ? 0 : (x < 0 ? -1 : 1));
103 inline ivec
sign_i(
const ivec &x) {
return apply_function<int>(
sign_i, x); }
105 inline imat
sign_i(
const imat &x) {
return apply_function<int>(
sign_i, x); }
110 inline ivec
sgn_i(
const ivec &x) {
return apply_function<int>(
sign_i, x); }
112 inline imat
sgn_i(
const imat &x) {
return apply_function<int>(
sign_i, x); }
117 return (x == 0.0 ? 0 : (x < 0.0 ? -1 : 1));
123 inline vec
sqrt(
const vec &x) {
return apply_function<double>(
std::sqrt, x); }
125 inline mat
sqrt(
const mat &x) {
return apply_function<double>(
std::sqrt, x); }
131 ITPP_EXPORT
double gamma(
double x);
133 ITPP_EXPORT vec
gamma(
const vec &x);
135 ITPP_EXPORT mat
gamma(
const mat &x);
141 inline double rem(
double x,
double y) {
return fmod(x, y); }
143 inline vec
rem(
const vec &x,
double y)
145 return apply_function<double>(
rem, x, y);
148 inline vec
rem(
double x,
const vec &y)
150 return apply_function<double>(
rem, x, y);
153 inline mat
rem(
const mat &x,
double y)
155 return apply_function<double>(
rem, x, y);
158 inline mat
rem(
double x,
const mat &y)
160 return apply_function<double>(
rem, x, y);
166 inline int mod(
int k,
int n)
168 return (n == 0) ? k : (k - n *
floor_i(
static_cast<double>(k) / n));
175 ITPP_EXPORT
double fact(
int index);
181 ITPP_EXPORT
double binom(
int n,
int k);
184 ITPP_EXPORT
int binom_i(
int n,
int k);
187 ITPP_EXPORT
double log_binom(
int n,
int k);
199 ITPP_EXPORT
int gcd(
int a,
int b);
205 ITPP_EXPORT vec
real(
const cvec &x);
207 ITPP_EXPORT mat
real(
const cmat &x);
209 ITPP_EXPORT vec
imag(
const cvec &x);
211 ITPP_EXPORT mat
imag(
const cmat &x);
214 ITPP_EXPORT vec
arg(
const cvec &x);
216 ITPP_EXPORT mat
arg(
const cmat &x);
225 inline cvec
conj(
const cvec &x)
228 return apply_function<std::complex<double> >(
std::conj, x);
231 inline cmat
conj(
const cmat &x)
233 return apply_function<std::complex<double> >(
std::conj, x);
236 ITPP_EXPORT cvec
conj(
const cvec &x);
240 ITPP_EXPORT cmat
conj(
const cmat &x);
247 #endif // #ifndef ELEM_MATH_H
double binom(int n, int k)
Compute the binomial coefficient "n over k".
vec arg(const cvec &data)
Argument (angle)
double gamma(double x)
Deprecated gamma function - please use tgamma() instead.
vec imag(const cvec &data)
Imaginary part of complex values.
cvec conj(const cvec &x)
Conjugate of complex value.
int mod(int k, int n)
Calculates the modulus, i.e. the signed reminder after division.
int sgn_i(int x)
Signum function.
int binom_i(int n, int k)
Compute the binomial coefficient "n over k".
int floor_i(double x)
The nearest smaller integer.
vec angle(const cvec &x)
Angle.
double rem(double x, double y)
The reminder of the division x/y.
double sgn(double x)
Signum function.
mat sqrt(const mat &x)
Square root of the elements.
cmat conj(const cmat &x)
Conjugate of complex value.
imat abs(const imat &x)
Absolute value.
vec sqr(const cvec &data)
Absolute square of elements.
bin abs(const bin &inbin)
absolute value of bin
vec sqrt(const vec &x)
Square root of the elements.
int sign_i(int x)
Signum function.
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.
double sign(double x)
Signum function.
int gcd(int a, int b)
Compute the greatest common divisor (GCD) g of the elements a and b.
vec real(const cvec &data)
Real part of complex values.
double fact(int index)
Calculates factorial coefficient for index <= 170.
Definitions of converters between different vector and matrix types.
Generated on Sun Jan 3 2021 11:31:33 for IT++ by Doxygen 1.8.20