vSMC
vSMC: Scalable Monte Carlo
Namespaces | Macros | Functions
vmath.hpp File Reference
#include <vsmc/internal/config.h>
#include <vsmc/math/constants.hpp>
#include <cmath>
#include <mkl.h>

Go to the source code of this file.

Namespaces

 vsmc
 

Macros

#define VSMC_DEFINE_MATH_VMATH_1(func, name)
 
#define VSMC_DEFINE_MATH_VMATH_2(func, name)
 
#define VSMC_DEFINE_MATH_VMATH_B(op, name)
 
#define VSMC_DEFINE_MATH_VMATH_SV(op, name)
 
#define VSMC_DEFINE_MATH_VMATH_VML_1(func, name)
 
#define VSMC_DEFINE_MATH_VMATH_VML_2(func, name)
 
#define VSMC_DEFINE_MATH_VMATH_VS(op, name)
 

Functions

void vsmc::abs (std::size_t n, const float *a, float *y)
 
void vsmc::abs (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::abs (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = |a_i|\). More...
 
void vsmc::acos (std::size_t n, const float *a, float *y)
 
void vsmc::acos (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::acos (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \arccos(a_i)\). More...
 
void vsmc::acosh (std::size_t n, const float *a, float *y)
 
void vsmc::acosh (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::acosh (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \mathrm{arc}\cosh(a_i)\). More...
 
void vsmc::add (std::size_t n, const double *a, const double *b, double *y)
 
void vsmc::add (std::size_t n, const float *a, const float *b, float *y)
 
template<typename T >
void vsmc::add (std::size_t n, const T *a, const T *b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i + b_i\). More...
 
template<typename T >
void vsmc::add (std::size_t n, const T *a, T b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i + b\). More...
 
template<typename T >
void vsmc::add (std::size_t n, T a, const T *b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a + b_i\). More...
 
void vsmc::asin (std::size_t n, const float *a, float *y)
 
void vsmc::asin (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::asin (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \arcsin(a_i)\). More...
 
void vsmc::asinh (std::size_t n, const float *a, float *y)
 
void vsmc::asinh (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::asinh (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \mathrm{arc}\sinh(a_i)\). More...
 
void vsmc::atan (std::size_t n, const float *a, float *y)
 
void vsmc::atan (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::atan (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \arctan(a_i)\). More...
 
void vsmc::atan2 (std::size_t n, const float *a, const float *b, float *y)
 
void vsmc::atan2 (std::size_t n, const double *a, const double *b, double *y)
 
template<typename T >
void vsmc::atan2 (std::size_t n, const T *a, const T *b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \arctan(a_i / b_i)\) with signs to determine the quadrant. More...
 
void vsmc::atanh (std::size_t n, const float *a, float *y)
 
void vsmc::atanh (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::atanh (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \mathrm{arc}\tanh(a_i)\). More...
 
void vsmc::cbrt (std::size_t n, const float *a, float *y)
 
void vsmc::cbrt (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::cbrt (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \sqrt[3]{a_i}\). More...
 
void vsmc::cdfnorm (std::size_t n, const float *a, float *y)
 
void vsmc::cdfnorm (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::cdfnorm (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = 1 - \mathrm{Erfc}(a_i / \sqrt{2}) / 2\), the standard Normal CDF. More...
 
void vsmc::cdfnorminv (std::size_t n, const float *a, float *y)
 
void vsmc::cdfnorminv (std::size_t n, const double *a, double *y)
 
void vsmc::cos (std::size_t n, const float *a, float *y)
 
void vsmc::cos (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::cos (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \sin(a_i)\). More...
 
void vsmc::cosh (std::size_t n, const float *a, float *y)
 
void vsmc::cosh (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::cosh (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \cosh(a_i)\). More...
 
void vsmc::div (std::size_t n, const double *a, const double *b, double *y)
 
void vsmc::div (std::size_t n, const float *a, const float *b, float *y)
 
template<typename T >
void vsmc::div (std::size_t n, const T *a, const T *b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i / b_i\). More...
 
template<typename T >
void vsmc::div (std::size_t n, const T *a, T b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i / b\). More...
 
template<typename T >
void vsmc::div (std::size_t n, T a, const T *b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a / b_i\). More...
 
void vsmc::erf (std::size_t n, const float *a, float *y)
 
void vsmc::erf (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::erf (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \mathrm{Erf}(a_i)\). More...
 
void vsmc::erfc (std::size_t n, const float *a, float *y)
 
void vsmc::erfc (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::erfc (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \mathrm{Erfc}(a_i) = \mathrm{Erf}(1 - a_i)\). More...
 
void vsmc::erfcinv (std::size_t n, const float *a, float *y)
 
void vsmc::erfcinv (std::size_t n, const double *a, double *y)
 
void vsmc::erfinv (std::size_t n, const float *a, float *y)
 
void vsmc::erfinv (std::size_t n, const double *a, double *y)
 
void vsmc::exp (std::size_t n, const float *a, float *y)
 
void vsmc::exp (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::exp (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = e^{a_i}\). More...
 
template<typename T >
void vsmc::exp10 (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = 10^{a_i}\). More...
 
template<typename T >
void vsmc::exp2 (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = 2^{a_i}\). More...
 
void vsmc::expm1 (std::size_t n, const float *a, float *y)
 
void vsmc::expm1 (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::expm1 (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = e^{a_i} - 1\). More...
 
template<typename T >
void vsmc::fma (std::size_t n, const T *a, const T *b, const T *c, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i * b_i + c_i\). More...
 
template<typename T >
void vsmc::fma (std::size_t n, const T *a, const T *b, T c, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i * b_i + c\). More...
 
template<typename T >
void vsmc::fma (std::size_t n, const T *a, T b, const T *c, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i * b + c_i\). More...
 
template<typename T >
void vsmc::fma (std::size_t n, const T *a, T b, T c, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i * b + c\). More...
 
template<typename T >
void vsmc::fma (std::size_t n, T a, const T *b, const T *c, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a * b_i + c_i\). More...
 
template<typename T >
void vsmc::fma (std::size_t n, T a, const T *b, T c, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a * b_i + c\). More...
 
template<typename T >
void vsmc::fma (std::size_t n, T a, T b, const T *c, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a * b + c_i\). More...
 
void vsmc::hypot (std::size_t n, const float *a, const float *b, float *y)
 
void vsmc::hypot (std::size_t n, const double *a, const double *b, double *y)
 
template<typename T >
void vsmc::hypot (std::size_t n, const T *a, const T *b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \sqrt{a_i^2 + b_i^2}\). More...
 
void vsmc::inv (std::size_t n, const double *a, double *y)
 
void vsmc::inv (std::size_t n, const float *a, float *y)
 
template<typename T >
void vsmc::inv (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i^{-1}\). More...
 
void vsmc::invcbrt (std::size_t n, const double *a, double *y)
 
void vsmc::invcbrt (std::size_t n, const float *a, float *y)
 
template<typename T >
void vsmc::invcbrt (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = 1 / \sqrt[3]{a_i}\). More...
 
void vsmc::invsqrt (std::size_t n, const float *a, float *y)
 
void vsmc::invsqrt (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::invsqrt (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = 1 / \sqrt{a_i}\). More...
 
void vsmc::lgamma (std::size_t n, const float *a, float *y)
 
void vsmc::lgamma (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::lgamma (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \ln\Gamma(a_i)\), logarithm of the Gamma function. More...
 
void vsmc::linear_frac (std::size_t n, const float *a, const float *b, float beta_a, float beta_b, float mu_a, float mu_b, float *y)
 
void vsmc::linear_frac (std::size_t n, const double *a, const double *b, double beta_a, double beta_b, double mu_a, double mu_b, double *y)
 
template<typename T >
void vsmc::linear_frac (std::size_t n, const T *a, const T *b, T beta_a, T beta_b, T mu_a, T mu_b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = (\beta_a a_i + \mu_a) / (\beta_b b_i + \mu_b)\). More...
 
void vsmc::log (std::size_t n, const float *a, float *y)
 
void vsmc::log (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::log (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \log(a_i)\). More...
 
void vsmc::log10 (std::size_t n, const float *a, float *y)
 
void vsmc::log10 (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::log10 (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \log_{10}(a_i)\). More...
 
void vsmc::log1p (std::size_t n, const float *a, float *y)
 
void vsmc::log1p (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::log1p (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \log(a_i + 1)\). More...
 
template<typename T >
void vsmc::log2 (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \log_2(a_i)\). More...
 
void vsmc::mul (std::size_t n, const float *a, const float *b, float *y)
 
void vsmc::mul (std::size_t n, const double *a, const double *b, double *y)
 
template<typename T >
void vsmc::mul (std::size_t n, const T *a, const T *b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i b_i\). More...
 
template<typename T >
void vsmc::mul (std::size_t n, const T *a, T b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i b\). More...
 
template<typename T >
void vsmc::mul (std::size_t n, T a, const T *b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a b_i\). More...
 
void vsmc::pow (std::size_t n, const float *a, const float *b, float *y)
 
void vsmc::pow (std::size_t n, const double *a, const double *b, double *y)
 
void vsmc::pow (std::size_t n, const float *a, float b, float *y)
 
void vsmc::pow (std::size_t n, const double *a, double b, double *y)
 
template<typename T >
void vsmc::pow (std::size_t n, const T *a, const T *b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i^{b_i}\). More...
 
template<typename T >
void vsmc::pow (std::size_t n, const T *a, T b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i^b\). More...
 
void vsmc::pow2o3 (std::size_t n, const double *a, double *y)
 
void vsmc::pow2o3 (std::size_t n, const float *a, float *y)
 
template<typename T >
void vsmc::pow2o3 (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i^{2/3}\). More...
 
void vsmc::pow3o2 (std::size_t n, const double *a, double *y)
 
void vsmc::pow3o2 (std::size_t n, const float *a, float *y)
 
template<typename T >
void vsmc::pow3o2 (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i^{3/2}\). More...
 
void vsmc::sin (std::size_t n, const float *a, float *y)
 
void vsmc::sin (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::sin (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \cos(a_i)\). More...
 
void vsmc::sincos (std::size_t n, const float *a, float *y, float *z)
 
void vsmc::sincos (std::size_t n, const double *a, double *y, double *z)
 
template<typename T >
void vsmc::sincos (std::size_t n, const T *a, T *y, T *z)
 For \(i=1,\ldots,n\), compute \(y_i = \sin(a_i), z_i = \cos(a_i)\). More...
 
void vsmc::sinh (std::size_t n, const double *a, double *y)
 
void vsmc::sinh (std::size_t n, const float *a, float *y)
 
template<typename T >
void vsmc::sinh (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \sinh(a_i)\). More...
 
void vsmc::sqr (std::size_t n, const float *a, float *y)
 
void vsmc::sqr (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::sqr (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i^2\). More...
 
void vsmc::sqrt (std::size_t n, const float *a, float *y)
 
void vsmc::sqrt (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::sqrt (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \sqrt{a_i}\). More...
 
void vsmc::sub (std::size_t n, const double *a, const double *b, double *y)
 
void vsmc::sub (std::size_t n, const float *a, const float *b, float *y)
 
template<typename T >
void vsmc::sub (std::size_t n, const T *a, const T *b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i - b_i\). More...
 
template<typename T >
void vsmc::sub (std::size_t n, const T *a, T b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a_i - b\). More...
 
template<typename T >
void vsmc::sub (std::size_t n, T a, const T *b, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = a - b_i\). More...
 
void vsmc::tan (std::size_t n, const float *a, float *y)
 
void vsmc::tan (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::tan (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \tan(a_i)\). More...
 
void vsmc::tanh (std::size_t n, const double *a, double *y)
 
void vsmc::tanh (std::size_t n, const float *a, float *y)
 
template<typename T >
void vsmc::tanh (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \tanh(a_i)\). More...
 
void vsmc::tgamm (std::size_t n, const float *a, float *y)
 
void vsmc::tgamm (std::size_t n, const double *a, double *y)
 
template<typename T >
void vsmc::tgamma (std::size_t n, const T *a, T *y)
 For \(i=1,\ldots,n\), compute \(y_i = \Gamma(a_i)\), the Gamma function. More...
 

Macro Definition Documentation

#define VSMC_DEFINE_MATH_VMATH_1 (   func,
  name 
)
Value:
template <typename T> \
inline void name(std::size_t n, const T *a, T *y) \
{ \
for (std::size_t i = 0; i != n; ++i) \
y[i] = func(a[i]); \
}

Definition at line 43 of file vmath.hpp.

#define VSMC_DEFINE_MATH_VMATH_2 (   func,
  name 
)
Value:
template <typename T> \
inline void name(std::size_t n, const T *a, const T *b, T *y) \
{ \
for (std::size_t i = 0; i != n; ++i) \
y[i] = func(a[i], b[i]); \
}

Definition at line 51 of file vmath.hpp.

#define VSMC_DEFINE_MATH_VMATH_B (   op,
  name 
)
Value:
template <typename T> \
inline void name(std::size_t n, const T *a, const T *b, T *y) \
{ \
for (std::size_t i = 0; i != n; ++i) \
y[i] = a[i] op b[i]; \
}

Definition at line 59 of file vmath.hpp.

#define VSMC_DEFINE_MATH_VMATH_SV (   op,
  name 
)
Value:
template <typename T> \
inline void name(std::size_t n, T a, const T *b, T *y) \
{ \
for (std::size_t i = 0; i != n; ++i) \
y[i] = a op b[i]; \
}

Definition at line 75 of file vmath.hpp.

#define VSMC_DEFINE_MATH_VMATH_VML_1 (   func,
  name 
)
Value:
inline void name(std::size_t n, const float *a, float *y) \
{ \
::vs##func(static_cast<MKL_INT>(n), a, y); \
} \
inline void name(std::size_t n, const double *a, double *y) \
{ \
::vd##func(static_cast<MKL_INT>(n), a, y); \
}

Definition at line 85 of file vmath.hpp.

#define VSMC_DEFINE_MATH_VMATH_VML_2 (   func,
  name 
)
Value:
inline void name(std::size_t n, const float *a, const float *b, float *y) \
{ \
::vs##func(static_cast<MKL_INT>(n), a, b, y); \
} \
inline void name( \
std::size_t n, const double *a, const double *b, double *y) \
{ \
::vd##func(static_cast<MKL_INT>(n), a, b, y); \
}

Definition at line 95 of file vmath.hpp.

#define VSMC_DEFINE_MATH_VMATH_VS (   op,
  name 
)
Value:
template <typename T> \
inline void name(std::size_t n, const T *a, T b, T *y) \
{ \
for (std::size_t i = 0; i != n; ++i) \
y[i] = a[i] op b; \
}

Definition at line 67 of file vmath.hpp.