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"
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... | |
Declaration of some general purpose utilities.
Definition in file Common.h.
enum Core::EvolModeType |
The various evolution modes.
Each corresponds to a different system of differential equations with different variables.
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.
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.
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.
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.
x0 | The abscissa of the first point though which the function should pass. |
y0 | The oordinate of the first point though which the function should pass. |
x1 | The abscissa of the second point though which the function should pass. |
y1 | The oordinate of the second point though which the function should pass. |
dy0 | The derivative of the function at the first point |
dy1 | The derivative of the function at the second point |
extremum_y | A location to store the value the function takes at the extremum. |
Definition at line 251 of file Common.cpp.
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.
x0 | The abscissa of the first point though which the function should pass. |
y0 | The oordinate of the first point though which the function should pass. |
x1 | The abscissa of the second point though which the function should pass. |
y1 | The oordinate of the second point though which the function should pass. |
dy0 | The derivative of the function at the first point (optional). |
dy1 | The derivative of the function at the second point (optional). |
Definition at line 68 of file Common.cpp.
|
inline |
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.
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.
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.
gsl_vector* Core::polynomial_coefficients | ( | ITERATOR | x_i, |
ITERATOR | y_i, | ||
size_t | num_points | ||
) |
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.
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.
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.
std::valarray<double> Core::valarray_from_iterator | ( | ITERATOR_TYPE | values, |
unsigned | size | ||
) |
const double Core::Inf = std::numeric_limits<double>::infinity() |