rsvs3D  0.0.0
Codes for the c++ implementation of the 3D RSVS
warning.cpp
1 
2 #include "warning.hpp"
3 
4 #include <cmath>
5 #include <ctime>
6 #include <fstream>
7 #include <iomanip>
8 #include <iostream>
9 
10 using namespace std;
11 double rsvs3d::Clock2ms(int clockCycles)
12 {
13  return (double(clockCycles) / double(CLOCKS_PER_SEC) * 1000.0);
14 }
15 
16 #ifndef TIME_EXEC
17 #pragma GCC diagnostic push
18 #pragma GCC diagnostic ignored "-Wunused-parameter"
19 #endif
20 int rsvs3d::TimeStamp(const char *str, int start_s)
21 {
22  int stop_s = clock();
23 #ifdef TIME_EXEC
24  if (str != NULL)
25  {
26  cout << str << " " << std::setw(5) << Clock2ms(stop_s - start_s) << "ms; ";
27  }
28 #endif
29  return (stop_s);
30 }
31 #ifndef TIME_EXEC
32 #pragma GCC diagnostic pop
33 #endif
34 
35 void ThrowWarning(const char *message)
36 {
37  cerr << message << endl;
38 }
39 
40 double rsvs3d::SignedLogScale(double in)
41 {
42  double out = sign(in);
43  double logeps = -15; // aprox log10(__DBL_EPSILON__)
44  if (out == 0)
45  {
46  // Do nothing
47  }
48  else if (fabs(in) > __DBL_EPSILON__)
49  {
50  out = out * (log10(fabs(in)) - logeps + 1.0);
51  }
52  else
53  {
54  out = -out * 1.0 / (log10(fabs(in)) - logeps + 1.0);
55  }
56 
57  return out;
58 }
int sign(T val)
Returns the sign of a type comparable to 0.
Definition: warning.hpp:215
double SignedLogScale(double in)
Returns a signed logscale useful for plotting data.
Definition: warning.cpp:40
Provides the error and warning system used by the RSVS3D project.