libode
Easy to compile, fast ODE integrators as C++ classes
Loading...
Searching...
No Matches
ode_util.cc
Go to the documentation of this file.
1
2
3#include "ode_util.h"
4
5namespace ode {
6
7double ode_max2 (double a, double b) {
8 if (a > b) return(a);
9 return(b);
10}
11
12double ode_min2 (double a, double b) {
13 if (a < b) return(a);
14 return(b);
15}
16
17bool ode_is_close (double a, double b, double thresh) {
18
19 //get magnitudes
20 double absa = fabs(a);
21 double absb = fabs(b);
22 double absd = fabs(a - b);
23 //check relative differnence against a threshold
24 if ((absd/absa < thresh) && (absd/absb < thresh))
25 return(true);
26 //otherwise the numbers aren't close
27 return(false);
28}
29
30} // namespace ode
double ode_min2(double a, double b)
Simple minimum of two doubles.
Definition ode_util.cc:12
double ode_max2(double a, double b)
Simple maximum of two doubles.
Definition ode_util.cc:7
bool ode_is_close(double a, double b, double thresh)
Checks if two numbers are very close to each other.
Definition ode_util.cc:17