Samchon Framework for CPP  1.0.0
samchon::library::Math Class Reference

Utility of Math. More...

#include <Math.hpp>

Static Public Member Functions

static auto random () -> double
 Get a random value. More...
 
static auto degree_to_radian (double) -> double
 Convert degree to radian. More...
 
static auto radian_to_degree (double) -> double
 Convert radian to degree. More...
 
template<typename _Cont , typename T = _Cont::value_type>
static auto minimum (const _Cont &container) -> IndexPair< T >
 Calculate minimum value with its index. More...
 
template<typename _Cont , typename T = _Cont::value_type>
static auto maximum (const _Cont &container) -> IndexPair< T >
 Calculate maximum value with its index. More...
 
template<typename _Cont , typename T = _Cont::value_type>
static auto mean (const _Cont &container) -> double
 Calculate average. More...
 
template<typename _Cont , typename T = _Cont::value_type>
static auto median (const _Cont &container) -> double
 Get median value. More...
 
template<typename _Cont , typename T = _Cont::value_type>
static auto mode (const _Cont &container) -> T
 Find mode value. More...
 
template<typename _Cont , typename T = _Cont::value_type>
static auto stdev_p (const _Cont &container) -> double
 Square root of a variance_p. More...
 
template<typename _Cont , typename T = _Cont::value_type>
static auto stdev_s (const _Cont &container) -> double
 Square root of a variance_s. More...
 
template<typename _Cont , typename T = _Cont::value_type>
static auto variance_p (const _Cont &container) -> double
 Calculate standard deviation for all population. More...
 
template<typename _Cont , typename T = _Cont::value_type>
static auto variance_s (const _Cont &container) -> double
 Calculate variance for sample. More...
 

Static Public Attributes

static const double E = exp(1.0)
 Exponent. More...
 
static const double PI = 3.141592653589793
 ¥ð, Number Pi More...
 
static const double LN2 = 1.0 / log2(E)
 loge2 More...
 
static const double LN10 = 1.0 / log10(E)
 loge10 More...
 
static const double LOG2E = log2(E)
 log2e More...
 
static const double LOG10E = log10(E)
 log10e More...
 
static const double SQRT1_2 = sqrt(.5)
 Squart root of 0.5. More...
 
static const double SQRT2 = sqrt(2.0)
 Squart root of 2. More...
 

Detailed Description

Utility of Math.

Provides some static values and mathmatical methods.

library_math.png
See also
samchon::library
Author
Jeongho Nam http://samchon.org

Definition at line 23 of file Math.hpp.

Member Function Documentation

auto Math::random ( ) -> double
static

Get a random value.

Returns a random value following uniform distribution

Returns
The random value

Definition at line 38 of file Math.cpp.

Referenced by samchon::library::GeneticAlgorithm< GeneArray, Compare, Gene >::crossover(), samchon::example::tsp::GeometryPoint::GeometryPoint(), samchon::library::GeneticAlgorithm< GeneArray, Compare, Gene >::mutate(), and samchon::library::GeneticAlgorithm< GeneArray, Compare, Gene >::selection().

Here is the caller graph for this function:

auto Math::degree_to_radian ( double  val) -> double
static

Convert degree to radian.

Definition at line 26 of file Math.cpp.

Referenced by samchon::example::tsp::GeometryPoint::calcDistance().

Here is the caller graph for this function:

auto Math::radian_to_degree ( double  val) -> double
static

Convert radian to degree.

Definition at line 30 of file Math.cpp.

Referenced by samchon::example::tsp::GeometryPoint::calcDistance().

Here is the caller graph for this function:

template<typename _Cont , typename T = _Cont::value_type>
static auto samchon::library::Math::minimum ( const _Cont &  container) -> IndexPair<T>
inlinestatic

Calculate minimum value with its index.

Template Parameters
_ContType of the container
_Ty

Value type of the container.

Do not modify the default template argument.

Parameters
containerContainer to find its minimum value
Returns
Pair of minimum value and its index

Definition at line 143 of file Math.hpp.

Referenced by samchon::library::StringUtil::substituteSQL().

Here is the caller graph for this function:

template<typename _Cont , typename T = _Cont::value_type>
static auto samchon::library::Math::maximum ( const _Cont &  container) -> IndexPair<T>
inlinestatic

Calculate maximum value with its index.

Template Parameters
_ContType of the container
_Ty

Value type of the container.

Do not modify the default template argument.

Parameters
containerContainer to find its minimum value
Returns
Pair of maximum value and its index

Definition at line 174 of file Math.hpp.

template<typename _Cont , typename T = _Cont::value_type>
static auto samchon::library::Math::mean ( const _Cont &  container) -> double
inlinestatic

Calculate average.

Template Parameters
_ContType of the container
_Ty

Value type of the container.

Do not modify the default template argument.

Parameters
containerContainer to find its mean
Returns
Average(mean) of the contaier

Definition at line 205 of file Math.hpp.

Referenced by variance_p(), and variance_s().

Here is the caller graph for this function:

template<typename _Cont , typename T = _Cont::value_type>
static auto samchon::library::Math::median ( const _Cont &  container) -> double
inlinestatic

Get median value.

Template Parameters
_ContType of the container
_Ty

Value type of the container.

Do not modify the default template argument.

Parameters
containerContainer to find its median
Returns
Median value of the container

Definition at line 226 of file Math.hpp.

template<typename _Cont , typename T = _Cont::value_type>
static auto samchon::library::Math::mode ( const _Cont &  container) -> T
inlinestatic

Find mode value.

Template Parameters
_ContType of the container
_Ty

Value type of the container.

Do not modify the default template argument.

Parameters
containerContainer to find its mode
Returns
Most appeared value in the container

Definition at line 258 of file Math.hpp.

template<typename _Cont , typename T = _Cont::value_type>
static auto samchon::library::Math::stdev_p ( const _Cont &  container) -> double
inlinestatic

Square root of a variance_p.

$\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}$

Template Parameters
_ContType of the container
_Ty

Value type of the container.

Do not modify the default template argument.

Parameters
containerContainer to find its standard deviation
Returns
Standard deviation of the container

Definition at line 282 of file Math.hpp.

template<typename _Cont , typename T = _Cont::value_type>
static auto samchon::library::Math::stdev_s ( const _Cont &  container) -> double
inlinestatic

Square root of a variance_s.

Template Parameters
_ContType of the container
_Ty

Value type of the container.

Do not modify the default template argument.

Parameters
containerContainer to find its variance
Returns
Variance of the container

Definition at line 293 of file Math.hpp.

template<typename _Cont , typename T = _Cont::value_type>
static auto samchon::library::Math::variance_p ( const _Cont &  container) -> double
inlinestatic

Calculate standard deviation for all population.

Template Parameters
_ContType of the container
_Ty

Value type of the container.

Do not modify the default template argument.

Parameters
containerContainer to find its standard deviation
Returns
Standard deviation of the container

Definition at line 310 of file Math.hpp.

References mean().

Here is the call graph for this function:

template<typename _Cont , typename T = _Cont::value_type>
static auto samchon::library::Math::variance_s ( const _Cont &  container) -> double
inlinestatic

Calculate variance for sample.

Template Parameters
_ContType of the container
_Ty

Value type of the container.

Do not modify the default template argument.

Parameters
containerContainer to find its variance
Returns
Variance of the container

Definition at line 333 of file Math.hpp.

References mean().

Here is the call graph for this function:

Member Data Documentation

const double Math::E = exp(1.0)
static

Exponent.

A mathematical constant for the base of natural logarithms, expressed as e. The approximate value of e is 2.71828182845905.

Definition at line 36 of file Math.hpp.

const double Math::PI = 3.141592653589793
static

¥ð, Number Pi

A mathematical constant for the ratio of the circumference of a circle to its diameter, expressed as pi, with a value of 3.141592653589793.

Definition at line 45 of file Math.hpp.

const double Math::LN2 = 1.0 / log2(E)
static

loge2

A mathematical constant for the natural logarithm of 2, expressed as loge2, with an approximate value of 0.6931471805599453.

Definition at line 54 of file Math.hpp.

const double Math::LN10 = 1.0 / log10(E)
static

loge10

A mathematical constant for the natural logarithm of 10, expressed as loge10, with an approximate value of 2.302585092994046.

Definition at line 63 of file Math.hpp.

const double Math::LOG2E = log2(E)
static

log2e

A mathematical constant for the base-2 logarithm of the constant e, expressed as log2e, with an approximate value of 1.442695040888963387.

Definition at line 72 of file Math.hpp.

const double Math::LOG10E = log10(E)
static

log10e

A mathematical constant for the base-10 logarithm of the constant e (Math.E), expressed as log10e, with an approximate value of 0.4342944819032518. The Math.log() method computes the natural logarithm of a number. Multiply the result of Math.log() by Math.LOG10E to obtain the base-10 logarithm.

Definition at line 83 of file Math.hpp.

const double Math::SQRT1_2 = sqrt(.5)
static

Squart root of 0.5.

A mathematical constant for the square root of one-half, with an approximate value of 0.7071067811865476.

Definition at line 93 of file Math.hpp.

const double Math::SQRT2 = sqrt(2.0)
static

Squart root of 2.

A mathematical constant for the square root of 2, with an approximate value of 1.4142135623730951.

Definition at line 102 of file Math.hpp.


The documentation for this class was generated from the following files: