Samchon Framework for CPP  1.0.0
Math.cpp
1 #include <samchon/library/Math.hpp>
2 #include <cmath>
3 #include <random>
4 
5 using namespace std;
6 using namespace samchon;
7 using namespace samchon::library;
8 
9 /* ========================================================
10  STATIC VARIABLES
11 ======================================================== */
12 const double Math::E = exp(1.0);
13 const double Math::PI = 3.141592653589793;
14 
15 const double Math::LN2 = 1.0 / log2(E);
16 const double Math::LN10 = 1.0 / log10(E);
17 const double Math::LOG2E = log2(E);
18 const double Math::LOG10E = log10(E);
19 
20 const double Math::SQRT1_2 = sqrt(.5);
21 const double Math::SQRT2 = sqrt(2.0);
22 
23 /* ========================================================
24  PIE
25 ======================================================== */
26 auto Math::degree_to_radian(double val) -> double
27 {
28  return val * PI / 180.0;
29 }
30 auto Math::radian_to_degree(double val) -> double
31 {
32  return val * 180.0 / PI;
33 }
34 
35 /* ========================================================
36  RANDOM
37 ======================================================== */
38 auto Math::random() -> double
39 {
40  static random_device device;
41  static uniform_real_distribution<double> distribution(0.0, 1.0);
42 
43  return distribution(device);
44 }
Definition: RWMutex.hpp:4
Package of libraries.
Definition: library.hpp:84
Top level namespace of products built from samchon.
Definition: ByteArray.hpp:7