Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
Common.cpp File Reference

The implementation of some of the utility functions. More...

#include "Common.h"
+ Include dependency graph for Common.cpp:

Go to the source code of this file.

Functions

std::ostream & std::operator<< (std::ostream &os, const std::valarray< double > &arr)
 Outputs a valarray as a sequence of ', ' separated values. More...
 
std::ostream & std::operator<< (std::ostream &os, const std::list< double > &l)
 Outputs a list as a sequence of ', ' separated values. More...
 
std::ostream & Core::operator<< (std::ostream &os, const Core::EvolModeType &evol_mode)
 More civilized output for EvolModeType variables. More...
 
std::valarray< double > Core::solve_cubic (double c0, double c1, double c2, double c3)
 Solves the cubic equation \( \sum_{i=0}^3 c_i x^i=0 \). More...
 
double Core::estimate_zerocrossing ( double x0, double y0, double x1, double y1, double dy0=NaN, double dy1=NaN)
 Finds a zero of a smooth curve defined by the given points and derivatives. More...
 
double Core::quadratic_zerocrossing (double x0, double y0, double x1, double y1, double x2, double y2, double require_range_low=NaN, double require_range_high=NaN)
 Finds the abscissa of a zero of a quadratic defined by three points. More...
 
double Core::cubic_zerocrossing (double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double require_range_low=NaN, double require_range_high=NaN)
 Finds the abscissa of a zero of a cubic defined by four points. More...
 
double Core::estimate_extremum ( double x0, double y0, double x1, double y1, double dy0, double dy1, double *extremum_y=NULL)
 Finds an extremum of a cubic defined by two points and derivatives. More...
 
bool Core::indistinguishable (double x0, double y0, double x1, double y1)
 Are the two points indistinguishable (up to NUMERIC_SAFETY). More...
 
double Core::quadratic_extremum (double x0, double y0, double x1, double y1, double x2, double y2, double *extremum_y=NULL)
 Finds the abscissa of the extremum of the quadratic function passing through three points. More...
 
double Core::cubic_extremum (double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double *extremum_y=NULL, double require_range_low=NaN, double require_range_high=NaN)
 Finds the abscissa of an extremum of the cubic function passing through four points. More...
 
gsl_vector * Core::cubic_coefficients (double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
 Returns the polynomial coefficients of the cubic going through four points. More...
 

Variables

const double Core::NUMERIC_SAFETY =100.0*std::numeric_limits<double>::epsilon()
 

Detailed Description

The implementation of some of the utility functions.

Definition in file Common.cpp.

Function Documentation

◆ cubic_coefficients()

LIB_LOCAL gsl_vector * Core::cubic_coefficients ( double  x0,
double  y0,
double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
)

Returns the polynomial coefficients of the cubic going through four points.

The four points are (x0, y0), (x1, y1), (x2, y2), (x3, y3).

The return value is a GSL vector with the \(i^{th}\) component being the coefficient in front of \(x^i\).

The vector must be freed when no longer needed.

Definition at line 493 of file Common.cpp.

◆ cubic_extremum()

LIB_LOCAL double Core::cubic_extremum ( double  x0,
double  y0,
double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3,
double *  extremum_y = NULL,
double  require_range_low = NaN,
double  require_range_high = NaN 
)

Finds the abscissa of an extremum of the cubic function passing through four points.

The four points are (x0, y0), (x1, y1), (x2, y2), (x3, y3).

The input y values must not be monotonic.

If the optional extremum_y argument is not NULL, the location it points to gets overwritten with the value of the function at the extremum.

Definition at line 354 of file Common.cpp.

◆ cubic_zerocrossing()

LIB_LOCAL double Core::cubic_zerocrossing ( double  x0,
double  y0,
double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3,
double  require_range_low = NaN,
double  require_range_high = NaN 
)

Finds the abscissa of a zero of a cubic defined by four points.

The four points are (x0, y0), (x1, y1), (x2, y2), (x3, y3). Two of the function values must have opposite sign.

Definition at line 189 of file Common.cpp.

◆ estimate_extremum()

LIB_LOCAL double Core::estimate_extremum ( double  x0,
double  y0,
double  x1,
double  y1,
double  dy0,
double  dy1,
double *  extremum_y = NULL 
)

Finds an extremum of a cubic defined by two points and derivatives.

If the optional last argument is not NULL, the location it points to gets overwritten with the value of the function at the extremum.

The two derivatives must have an opposite sign.

Parameters
x0The abscissa of the first point though which the function should pass.
y0The oordinate of the first point though which the function should pass.
x1The abscissa of the second point though which the function should pass.
y1The oordinate of the second point though which the function should pass.
dy0The derivative of the function at the first point
dy1The derivative of the function at the second point
extremum_yA location to store the value the function takes at the extremum.

Definition at line 251 of file Common.cpp.

◆ estimate_zerocrossing()

LIB_LOCAL double Core::estimate_zerocrossing ( double  x0,
double  y0,
double  x1,
double  y1,
double  dy0 = NaN,
double  dy1 = NaN 
)

Finds a zero of a smooth curve defined by the given points and derivatives.

If no derivative information is provided, returns the abscissa at which the unique straight line passing through two points is zero.

If derivative informaiton is provided, returns one of the zeroes in the interval (x0, x1) of a cubic function passing through two points and having specified values of its derivatives at those points.

The two function values (y0 and y1) must have opposite sign.

Parameters
x0The abscissa of the first point though which the function should pass.
y0The oordinate of the first point though which the function should pass.
x1The abscissa of the second point though which the function should pass.
y1The oordinate of the second point though which the function should pass.
dy0The derivative of the function at the first point (optional).
dy1The derivative of the function at the second point (optional).

Definition at line 68 of file Common.cpp.

◆ indistinguishable()

bool Core::indistinguishable ( double  x0,
double  y0,
double  x1,
double  y1 
)

Are the two points indistinguishable (up to NUMERIC_SAFETY).

Definition at line 312 of file Common.cpp.

◆ operator<<() [1/3]

LIB_LOCAL std::ostream & std::operator<< ( std::ostream &  os,
const std::valarray< double > &  arr 
)

Outputs a valarray as a sequence of ', ' separated values.

Definition at line 11 of file Common.cpp.

◆ operator<<() [2/3]

LIB_LOCAL std::ostream & std::operator<< ( std::ostream &  os,
const std::list< double > &  l 
)

Outputs a list as a sequence of ', ' separated values.

Definition at line 21 of file Common.cpp.

◆ operator<<() [3/3]

LIB_LOCAL std::ostream & Core::operator<< ( std::ostream &  os,
const Core::EvolModeType evol_mode 
)

More civilized output for EvolModeType variables.

Definition at line 35 of file Common.cpp.

◆ quadratic_extremum()

LIB_LOCAL double Core::quadratic_extremum ( double  x0,
double  y0,
double  x1,
double  y1,
double  x2,
double  y2,
double *  extremum_y = NULL 
)

Finds the abscissa of the extremum of the quadratic function passing through three points.

The three points are (x0, y0), (x1, y1), (x2, y2).

If the optional last argument is not NULL, the location it points to gets overwritten with the value of the function at the extremum.

Definition at line 321 of file Common.cpp.

◆ quadratic_zerocrossing()

LIB_LOCAL double Core::quadratic_zerocrossing ( double  x0,
double  y0,
double  x1,
double  y1,
double  x2,
double  y2,
double  require_range_low = NaN,
double  require_range_high = NaN 
)

Finds the abscissa of a zero of a quadratic defined by three points.

The three points are (x0, y0), (x1, y1), (x2, y2). Two of the function values must have opposite sign.

Definition at line 138 of file Common.cpp.

◆ solve_cubic()

LIB_LOCAL std::valarray< double > Core::solve_cubic ( double  c0,
double  c1,
double  c2,
double  c3 
)

Solves the cubic equation \( \sum_{i=0}^3 c_i x^i=0 \).

Definition at line 49 of file Common.cpp.