MathCheck.cpp File Reference
#include "Math/Helpers.h"
#include "Math/ExtendedMath.h"
#include <sstream>

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )
31 {
32  std::stringstream ss;
33  for (Mdouble x=-6; x<6; x+=0.01)
34  {
35  Mdouble e = mathsFunc::exp(x);
36  Mdouble l = mathsFunc::log(e);
37  Mdouble c = mathsFunc::cos(x);
38  Mdouble s = mathsFunc::sin(x);
39  ss << x << " "
40  << e << " "
41  << l << " "
42  << c << " "
43  << s << "\n";
44  }
45  logger(INFO, "Execute 'gnuplot MathCheck.gnu' to view output");
46  helpers::writeToFile("MathCheck.data", ss.str());
47  helpers::writeToFile("MathCheck.gnu",
48  "set xlabel 'x'\n"
49  "p 'MathCheck.data' u 1:(log($2)) t 'log(Exp(x))',"
50  " 'MathCheck.data' u 1:3 t 'Log(Exp(x))', x,"
51  " 'MathCheck.data' u 1:5 t 'Sin(x)', sin(x),"
52  " 'MathCheck.data' u 1:4 t 'Cos(x)', cos(x)x"
53  "\n");
54  //WARNING: sin and cos are really bad outside (-pi,pi)
55  Mdouble d = 1e-15;
56  logger(INFO, "Accuracy of sin: %\n"
57  "Accuracy of cos: %",
59 }
double Mdouble
Definition: GeneralDefine.h:34
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
const Mdouble pi
Definition: ExtendedMath.h:45
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:58
Mdouble log(Mdouble Power)
Definition: ExtendedMath.cc:104
Mdouble cos(Mdouble x)
Definition: ExtendedMath.cc:64
Mdouble exp(Mdouble Exponent)
Definition: ExtendedMath.cc:84
Mdouble sin(Mdouble x)
Definition: ExtendedMath.cc:44

References mathsFunc::cos(), mathsFunc::exp(), INFO, mathsFunc::log(), logger, constants::pi, mathsFunc::sin(), and helpers::writeToFile().