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

Declaration of some general purpose utilities. More...

#include <list>
#include <valarray>
#include <limits>
#include <sstream>
#include <iostream>
#include <iterator>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_blas.h>
#include "gsl/gsl_poly.h"
#include <cassert>
#include "../Core/SharedLibraryExportMacros.h"
#include "Error.h"
#include "AstronomicalConstants.h"
#include "IncludeEigen.h"
+ Include dependency graph for Common.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  Core::EvolModeType { Core::LOCKED_SURFACE_SPIN, Core::BINARY, Core::SINGLE, Core::TABULATION }
 The various evolution modes. More...
 

Functions

template<typename ITERATOR_TYPE >
std::valarray< double > Core::valarray_from_iterator (ITERATOR_TYPE values, unsigned size)
 Creates a valarray from an iterator. More...
 
LIB_LOCAL std::valarray< double > Core::list_to_valarray (const std::list< double > &inlist)
 Creates a valarray containing the values in the given list. 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...
 
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...
 
template<class ITERATOR >
gsl_vector * Core::polynomial_coefficients (ITERATOR x_i, ITERATOR y_i, size_t num_points)
 Finds the polynomial that goes through the points iterated over by x_i and y_i. More...
 
std::ostream & Core::operator<< (std::ostream &os, const Core::EvolModeType &evol_mode)
 More civilized output for EvolModeType variables. More...
 
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...
 

Variables

const double Core::NaN = std::numeric_limits<double>::quiet_NaN()
 Not a number. More...
 
const double Core::Inf = std::numeric_limits<double>::infinity()
 Infinity. More...
 

Detailed Description

Declaration of some general purpose utilities.

Definition in file Common.h.

Enumeration Type Documentation

◆ EvolModeType

The various evolution modes.

Each corresponds to a different system of differential equations with different variables.

Enumerator
LOCKED_SURFACE_SPIN 

The surface rotation of one of the bodies is locked to a prescribed value.

BINARY 

Two bodies orbiting each other.

SINGLE 

There is only one body in the system (only its rotation evolves).

TABULATION 

Used as the mode to transform to from all other modes when storing the computed evolution.

Definition at line 42 of file Common.h.

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.

◆ list_to_valarray()

LIB_LOCAL std::valarray<double> Core::list_to_valarray ( const std::list< double > &  inlist)
inline

Creates a valarray containing the values in the given list.

Definition at line 74 of file Common.h.

◆ 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.

◆ polynomial_coefficients()

template<class ITERATOR >
gsl_vector* Core::polynomial_coefficients ( ITERATOR  x_i,
ITERATOR  y_i,
size_t  num_points 
)

Finds the polynomial that goes through the points iterated over by x_i and y_i.

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 233 of file Common.h.

◆ 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.

◆ valarray_from_iterator()

template<typename ITERATOR_TYPE >
std::valarray<double> Core::valarray_from_iterator ( ITERATOR_TYPE  values,
unsigned  size 
)

Creates a valarray from an iterator.

Definition at line 60 of file Common.h.

Variable Documentation

◆ Inf

const double Core::Inf = std::numeric_limits<double>::infinity()

Infinity.

Definition at line 36 of file Common.h.

◆ NaN

const double Core::NaN = std::numeric_limits<double>::quiet_NaN()

Not a number.

Definition at line 33 of file Common.h.