Functions and classes of general use for all unit tests. More...
#include "../Evolve/StopInformation.h"
#include "../Core/AstronomicalConstants.h"
#include <cpptest.h>
#include <valarray>
#include <sstream>
#include <cstdlib>
#include <string>
Go to the source code of this file.
Functions | |
bool | check_diff (double x, double y, double frac_tolerance, double abs_tolerance) |
Returns true iff \(|x-y|\leq\mathrm{abs\_tolerance} + \mathrm{frac\_tolerance}\cdot\max(|x|,|y|)\). More... | |
bool | check_diff (std::valarray< double > x, std::valarray< double > y, std::valarray< double > frac_tolerance, std::valarray< double > abs_tolerance) |
Returns true iff \( \forall i\ |x_i-y_i|\leq \mathrm{abs\_tolerance}_i + \mathrm{frac\_tolerance}_i\cdot\max(|x_i|,|y_i|)\). More... | |
bool | isEqual (double a, double b) |
double | getError (double predicted, double actual) |
bool | approxEqual (double predicted, double actual, double thres=0.02) |
double | orbital_angmom_from_freq (double m1, double m2, double freq, double e) |
The orbital angular momentum corresponding to the given frequency. More... | |
double | uniform_rand (double min, double max) |
Generates a uniformly distributed random number. More... | |
std::ostream & | operator<< (std::ostream &os, const std::valarray< std::valarray< double > > &poly_coef) |
Create a string with a description of the given stop info. More... | |
double | rand_value (double min, double max) |
A uniform random real value in the given range. More... | |
int | rand_value (int min, int max) |
A uniform integer value in the given range. More... | |
void | rand_poly_coef (std::valarray< std::valarray< double > > &poly_coef, double max_mass=-1) |
Fills the given valarray with a random set of polynomial coefficients. More... | |
std::valarray< std::valarray< double > > | rand_poly_coef (double max_mass=-1) |
Returns a random set of polynomial coefficients. More... | |
std::valarray< std::valarray< double > > | offset_age (const std::valarray< std::valarray< double > > &poly_coef, double age_offset) |
Returns new polynomial coefficienst such that output polynomial(mass, age+age_offset)=input polynomial(mass, age) More... | |
unsigned | next_binom_coef (unsigned n, unsigned m, unsigned nCm) |
Given n, m and (n)C(m) returns (n)C(m+1) More... | |
double | lag_from_lgQ (double lgQ) |
Converts lg(Q) to a tidal phase lag. More... | |
double | lag_from_lgQ (double lgQ, double mass_ratio) |
Transform Penev et. al 2012 lg(Q*) to phase lag. More... | |
Variables | |
const double | MIN_STELLAR_MASS = 0.4 |
The lowest stellar mass to use in tests in \(M_\odot\). More... | |
const double | MAX_LOW_MASS = 1.075 |
The boundary between high and low mass stars in \(M_\odot\). More... | |
const double | MAX_STELLAR_MASS = 1.3 |
The highest stellar mass to use in tests in \(M_\odot\). More... | |
const double | MIN_AGE = 1e-7 |
Most tests start at this age in Gyr. More... | |
const double | MAX_AGE = 10.0 |
Most tests end at this age in Gyr. More... | |
const double | MIN_PLANET_MASS = 10 |
The lower limit of the mass of random planets. More... | |
const double | MAX_PLANET_MASS = 80 |
The upper limit of the mass of random planets. More... | |
const double | MIN_PLANET_RADIUS = 5 |
The lower limit of the radius of random planets. More... | |
const double | MAX_PLANET_RADIUS = 15 |
The upper limit of the radius of random planets. More... | |
Functions and classes of general use for all unit tests.
Definition in file Common.h.
bool approxEqual | ( | double | predicted, |
double | actual, | ||
double | thres = 0.02 |
||
) |
Definition at line 33 of file Common.cpp.
bool check_diff | ( | double | x, |
double | y, | ||
double | frac_tolerance, | ||
double | abs_tolerance | ||
) |
Returns true iff \(|x-y|\leq\mathrm{abs\_tolerance} + \mathrm{frac\_tolerance}\cdot\max(|x|,|y|)\).
Definition at line 3 of file Common.cpp.
bool check_diff | ( | std::valarray< double > | x, |
std::valarray< double > | y, | ||
std::valarray< double > | frac_tolerance, | ||
std::valarray< double > | abs_tolerance | ||
) |
Returns true iff \( \forall i\ |x_i-y_i|\leq \mathrm{abs\_tolerance}_i + \mathrm{frac\_tolerance}_i\cdot\max(|x_i|,|y_i|)\).
Definition at line 11 of file Common.cpp.
double getError | ( | double | predicted, |
double | actual | ||
) |
Definition at line 27 of file Common.cpp.
bool isEqual | ( | double | a, |
double | b | ||
) |
Definition at line 23 of file Common.cpp.
double lag_from_lgQ | ( | double | lgQ | ) |
Converts lg(Q) to a tidal phase lag.
Definition at line 17 of file CInterface.cpp.
double lag_from_lgQ | ( | double | lgQ, |
double | mass_ratio | ||
) |
Transform Penev et. al 2012 lg(Q*) to phase lag.
lgQ | The old-style quality factor (log10) |
mass_ratio | The planet to star mass ratio |
Definition at line 145 of file Common.cpp.
unsigned next_binom_coef | ( | unsigned | n, |
unsigned | m, | ||
unsigned | nCm | ||
) |
Given n, m and (n)C(m) returns (n)C(m+1)
Definition at line 134 of file Common.cpp.
std::valarray< std::valarray<double> > offset_age | ( | const std::valarray< std::valarray< double > > & | poly_coef, |
double | age_offset | ||
) |
Returns new polynomial coefficienst such that output polynomial(mass, age+age_offset)=input polynomial(mass, age)
Returns new polynomial coefficienst such that output polynomial(age+age_offset)=input polynomial(age)
Returns new polynomial coefficienst such that output polynomial(mass, age+age_offset)=input polynomial(mass, age)
Definition at line 115 of file Common.cpp.
std::ostream& operator<< | ( | std::ostream & | os, |
const std::valarray< std::valarray< double > > & | poly_coef | ||
) |
Create a string with a description of the given stop info.
Outputs the mass and age polynomial defined by the given polynomial coefficients array
Definition at line 71 of file Common.cpp.
double orbital_angmom_from_freq | ( | double | m1, |
double | m2, | ||
double | freq, | ||
double | e | ||
) |
The orbital angular momentum corresponding to the given frequency.
Definition at line 39 of file Common.cpp.
void rand_poly_coef | ( | std::valarray< std::valarray< double > > & | poly_coef, |
double | max_mass = -1 |
||
) |
Fills the given valarray with a random set of polynomial coefficients.
Definition at line 90 of file Common.cpp.
std::valarray< std::valarray<double> > rand_poly_coef | ( | double | max_mass = -1 | ) |
Returns a random set of polynomial coefficients.
Definition at line 108 of file Common.cpp.
double rand_value | ( | double | min, |
double | max | ||
) |
A uniform random real value in the given range.
Definition at line 61 of file Common.cpp.
int rand_value | ( | int | min, |
int | max | ||
) |
A uniform integer value in the given range.
Definition at line 66 of file Common.cpp.
double uniform_rand | ( | double | min, |
double | max | ||
) |
Generates a uniformly distributed random number.
Seeding the random number generator is the caller's responsibility.
Definition at line 49 of file Common.cpp.
const double MAX_AGE = 10.0 |
const double MAX_LOW_MASS = 1.075 |
const double MAX_PLANET_MASS = 80 |
const double MAX_PLANET_RADIUS = 15 |
const double MAX_STELLAR_MASS = 1.3 |
const double MIN_AGE = 1e-7 |
const double MIN_PLANET_MASS = 10 |
const double MIN_PLANET_RADIUS = 5 |