PLaSK library
Loading...
Searching...
No Matches
math.hpp File Reference
#include <plask/config.hpp>
#include <cmath>
#include <limits>
#include <algorithm>
#include "exceptions.hpp"
#include <sstream>
Include dependency graph for math.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  plask::NaNImpl< T >
 This template is used by NaN function and have to be specialized to support new types (other than type supported by std::numeric_limits). More...
 
struct  plask::NaNImpl< std::complex< T > >
 Specialization of NaNImpl which adds support for complex numbers. More...
 
struct  plask::ZeroImpl< T >
 This template is used by Zero function and have to be specialized to support new types. More...
 
struct  plask::IllFormatedComplex
 Exception thrown by complex parser when complex number is ill-formated. More...
 
class  plask::AccurateSum
 Allow to compute sum of doubles much more accurate than directly. More...
 

Namespaces

namespace  plask
 Patterson quadrature for complex function along specified line.
 

Macros

#define M_PI   3.14159265358979323846
 
#define M_E   2.7182818284590452354
 
#define M_LOG2E   1.4426950408889634074
 
#define M_LOG10E   0.43429448190325182765
 
#define M_LN2   0.69314718055994530942
 
#define M_LN10   2.30258509299404568402
 
#define M_PI_2   1.57079632679489661923
 
#define M_PI_4   0.78539816339744830962
 
#define M_1_PI   0.31830988618379067154
 
#define M_2_PI   0.63661977236758134308
 
#define M_2_SQRTPI   1.12837916709551257390
 
#define M_SQRT2   1.41421356237309504880
 
#define M_SQRT1_2   0.70710678118654752440
 
#define _MATH_DEFINES_DEFINED
 

Functions

template<typename T >
constexpr std::remove_cv< typenamestd::remove_reference< T >::type >::type plask::NaN ()
 Construct NaN or its counterpart with given type T.
 
template<typename T >
constexpr std::remove_cv< typenamestd::remove_reference< T >::type >::type plask::Zero ()
 Construct NaN or its counterpart with given type T.
 
long double plask::conj (long double x)
 
double plask::conj (double x)
 
float plask::conj (float x)
 
bool plask::is_zero (double v, double abs_supremum=SMALL)
 Check if the real number is almost zero.
 
bool plask::is_zero (dcomplex v)
 Check if the complex number is almost zero.
 
bool plask::isnan (dcomplex v)
 Check if the complex number is NaN.
 
template<typename T >
plask::remove_nan (T val, const T nan=Zero< T >())
 Replace NaN with some specified value (zero by default).
 
plask::dcomplex plask::operator* (int a, const plask::dcomplex &b)
 
plask::dcomplex plask::operator* (const plask::dcomplex &a, int b)
 
plask::dcomplex plask::operator* (unsigned a, const plask::dcomplex &b)
 
plask::dcomplex plask::operator* (const plask::dcomplex &a, unsigned b)
 
plask::dcomplex plask::operator/ (int a, const plask::dcomplex &b)
 
plask::dcomplex plask::operator/ (const plask::dcomplex &a, int b)
 
plask::dcomplex plask::operator/ (unsigned a, const plask::dcomplex &b)
 
plask::dcomplex plask::operator/ (const plask::dcomplex &a, unsigned b)
 
double plask::abs2 (const dcomplex &x)
 
template<typename T >
const T & plask::clamp (const T &v, const T &min, const T &max)
 Clamp value to given range.
 
template<typename T >
bool plask::in_range (const T &v, const T &beg, const T &end)
 Check if value v is in given range [beg, end).
 
template<typename T1 , typename T2 , typename T3 >
auto plask::fma (T1 to_mult_1, T2 to_mult_2, T3 to_sum) -> decltype(to_mult_1 *to_mult_2+to_sum)
 Wrapper over std::fma witch works for all types.
 
float plask::fma (float to_mult_1, float to_mult_2, float to_sum)
 
double plask::fma (double to_mult_1, double to_mult_2, double to_sum)
 
long double plask::fma (long double to_mult_1, long double to_mult_2, long double to_sum)
 
bool plask::dbl_compare_eq (double x, double y)
 Check if two doubles are equals.
 
bool plask::dbl_compare_lt (double x, double y)
 Check if x is less than y.
 
bool plask::dbl_compare_gt (double x, double y)
 Check if x is greater than y.
 
bool plask::dbl_compare_lteq (double x, double y)
 Check if x is less or equals to y.
 
bool plask::dbl_compare_gteq (double x, double y)
 Check if x is greater or equals to y.
 
template<typename T >
std::complex< T > plask::parse_complex (std::string str_to_parse)
 Parse complex number in format: R+Ij, R, Ij, or (R, I), where R and I are floating point numbers (last is standard C++ format).
 
template std::complex< doubleplask::parse_complex< double > (std::string str_to_parse)
 

Variables

constexpr double plask::PI = M_PI
 
constexpr double plask::E = M_E
 
constexpr double plask::LOG2E = M_LOG2E
 
constexpr double plask::LOG10E = M_LOG10E
 
constexpr double plask::LN2 = M_LN2
 
constexpr double plask::LN10 = M_LN10
 
constexpr double plask::PI_2 = M_PI_2
 
constexpr double plask::PI_4 = M_PI_4
 
constexpr double plask::_1_PI = M_1_PI
 
constexpr double plask::_2_PI = M_2_PI
 
constexpr double plask::_2_SQRTPI = M_2_SQRTPI
 
constexpr double plask::SQRT2 = M_SQRT2
 
constexpr double plask::SQRT1_2 = M_SQRT1_2
 
constexpr double plask::PI_DOUBLED = 6.28318530717958647692
 
constexpr double plask::SMALL = std::numeric_limits<double>::epsilon()
 The numeric precision limit.
 
constexpr double plask::SMALL2 = SMALL*SMALL
 Squared numeric precision limit.
 

Macro Definition Documentation

◆ _MATH_DEFINES_DEFINED

#define _MATH_DEFINES_DEFINED

Definition at line 115 of file math.hpp.

◆ M_1_PI

#define M_1_PI   0.31830988618379067154

Definition at line 87 of file math.hpp.

◆ M_2_PI

#define M_2_PI   0.63661977236758134308

Definition at line 93 of file math.hpp.

◆ M_2_SQRTPI

#define M_2_SQRTPI   1.12837916709551257390

Definition at line 99 of file math.hpp.

◆ M_E

#define M_E   2.7182818284590452354

Definition at line 45 of file math.hpp.

◆ M_LN10

#define M_LN10   2.30258509299404568402

Definition at line 69 of file math.hpp.

◆ M_LN2

#define M_LN2   0.69314718055994530942

Definition at line 63 of file math.hpp.

◆ M_LOG10E

#define M_LOG10E   0.43429448190325182765

Definition at line 57 of file math.hpp.

◆ M_LOG2E

#define M_LOG2E   1.4426950408889634074

Definition at line 51 of file math.hpp.

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 39 of file math.hpp.

◆ M_PI_2

#define M_PI_2   1.57079632679489661923

Definition at line 75 of file math.hpp.

◆ M_PI_4

#define M_PI_4   0.78539816339744830962

Definition at line 81 of file math.hpp.

◆ M_SQRT1_2

#define M_SQRT1_2   0.70710678118654752440

Definition at line 111 of file math.hpp.

◆ M_SQRT2

#define M_SQRT2   1.41421356237309504880

Definition at line 105 of file math.hpp.