Math utility functions. More...
Functions | |
double | golden_section (double RHS(double x, void *context), double a, double b, double tol, int maxIts, void *context) |
Golden section minimization. | |
ml_matrix | rk0 (ml_matrix RHS(ml_matrix x, double t, void *context), ml_matrix &x, double h, double t, void *context) |
0th order Runge-Kutta integration algorithm with time as a RHS input | |
ml_matrix | rk4 (ml_matrix RHS(ml_matrix x, double t), ml_matrix &x, double h, double t) |
4th order Runge-Kutta integration algorithm with time as a RHS input | |
ml_matrix | rk4 (ml_matrix RHS(ml_matrix x, double t, void *context), ml_matrix &x, double h, double t, void *context) |
4th order Runge-Kutta integration algorithm with time as a RHS input and a context pointer | |
ml_matrix | rk4 (ml_matrix RHS(ml_matrix &x, ml_matrix &a), ml_matrix &x, double h, ml_matrix a) |
4th order Runge-Kutta integration algorithm with a matrix input to the RHS | |
double | pss_rem (double x, double y) |
Remainder function. | |
double | fix (double x) |
Round to 0. | |
double | r2p5 (double x) |
Round to nearest 0.5. | |
int | sct_sign (double x) |
Determine sign of number and return unitary value. | |
double | sct_max (double a, double b) |
Find maximum of two numbers. | |
double | unwrap (double angle) |
Unwrap radian values to (-pi,pi) interval. | |
ml_matrix | intersect_line_ellipsoid (const ml_matrix &p, const ml_matrix &u, const ml_matrix &e) |
Find the intersection between a line and an ellipsoid. | |
ml_matrix | p_gauss (int nMax, int mMax, double theta, ml_matrix &dp) |
Computes the Gaussian form of the Legendre functions and the first derivatives. | |
void | s_c_harm (const ml_matrix &a, int n, ml_matrix &s, ml_matrix &c) |
Generate a series of sine and cosine harmonics. | |
void | c_to_d_zoh (const ml_matrix &a, const ml_matrix &b, double dT, ml_matrix &aD, ml_matrix &bD) |
Compute a discrete-time linear system from a continuous system. | |
ml_matrix | expm (const ml_matrix &a) |
Compute the matrix exponential (of a square matrix only) using a power series expansion. | |
double | WrapPhase (double angle) |
Wrap a phase angle to keep its value between -pi and +pi. | |
ml_matrix | WrapPhase (ml_matrix angle) |
Wrap a vector of phase angles to keep their values between -pi and +pi. | |
ml_matrix | UnwrapPhase (ml_matrix theta) |
Unwrap a vector of angular values so they change continuously instead of wrapping. | |
ml_matrix | diff (ml_matrix a) |
Compute the difference between successive elements of a 1-D vector. | |
ml_matrix | delt_circ (ml_matrix x, ml_matrix y) |
Compute a delta in circular coordinates. | |
ml_matrix | circle_fit (ml_matrix x, ml_matrix y) |
Compute a delta in circular coordinates. | |
double | factorial (double n) |
Compute a factorial. | |
double | interp_2d (ml_matrix a, ml_matrix x, ml_matrix y, double xK, double yK) |
2D interpolation | |
double | newton_raphson (double f(double x, void *context), double df(double x, void *context), double x0, double tol, int nMax, void *context) |
1 dimensional root finder | |
double | secant (double RHS(double x, void *context), double x0, double x00, double tol, int nMax, void *context) |
1 dimensional root finder | |
ml_matrix | average_unit_vector (ml_matrix u1, ml_matrix u2) |
Average unit vector. | |
ml_matrix | pinv (ml_matrix a) |
Pseudo inverse. | |
ml_matrix | downhill_simplex (double RHS(const ml_matrix &x, void *context), ml_matrix &x, ml_matrix &options, void *context) |
Downhill simplex. | |
ml_matrix | orthogonalize (ml_matrix a) |
Orthogonalize. | |
ml_matrix | logistic (ml_matrix x) |
Logistic function. | |
double | logistic (double x) |
Logistic function. | |
double | interp_extrap_1d (ml_matrix a, ml_matrix x, double xK) |
1D interpolation and extrapolation | |
double | gaussian_multivariate_density (ml_matrix y, ml_matrix y_bar, ml_matrix P) |
Gaussian Mulivariate Normal Distribution function. | |
ml_matrix | roots_second_order (double a, double b, double c) |
Roots second order. | |
ml_matrix | roots_second_order (const ml_matrix &p) |
Roots second order. | |
double | trig_reduction (double a, double b, double c) |
Solve for beta: a*sin(beta)+b*cos(beta) = c. |
double golden_section | ( | double | RHSdouble x, void *context, |
double | a, | ||
double | b, | ||
double | tol, | ||
int | maxIts, | ||
void * | context | ||
) |
RHS | Right-hand side function definition |
a | Left range |
b | Right range |
tol | Tolerance |
maxIts | Maximum number of interations |
*context | to data from RSH |
ml_matrix rk0 | ( | ml_matrix | RHSml_matrix x, double t, void *context, |
ml_matrix & | x, | ||
double | h, | ||
double | t, | ||
void * | context | ||
) |
0th order Runge-Kutta integration algorithm with time as a RHS input
RHS actually does the propagation
RHS | Right-hand side function definition |
x | Current state |
h | Integration time step |
t | Current time |
*context | Pointer to data to be passed to RHS |
ml_matrix rk4 | ( | ml_matrix | RHSml_matrix x, double t, |
ml_matrix & | x, | ||
double | h, | ||
double | t | ||
) |
4th order Runge-Kutta integration algorithm with time as a RHS input
RHS | Right-hand side function definition |
x | Current state |
h | Integration time step |
t | Current time |
double pss_rem | ( | double | x, |
double | y | ||
) |
Remainder function.
x | Numerator |
y | Denominator |
double fix | ( | double | x ) |
Round to 0.
x | Number to be rounded |
double r2p5 | ( | double | x ) |
Round to nearest 0.5.
x | Number to be rounded |
int sct_sign | ( | double | x ) |
Determine sign of number and return unitary value.
x | Number |
double sct_max | ( | double | a, |
double | b | ||
) |
Find maximum of two numbers.
a | First number |
b | Second number |
double unwrap | ( | double | angle ) |
ml_matrix intersect_line_ellipsoid | ( | const ml_matrix & | p, |
const ml_matrix & | u, | ||
const ml_matrix & | e | ||
) |
Always returns the closest point. The line is defined by a point and unit vectors.
p | (3,1) Point |
u | (3,1) Unit vector |
e | (3,1) (a,b,c) semi-axes of ellipsoid |
ml_matrix p_gauss | ( | int | nMax, |
int | mMax, | ||
double | theta, | ||
ml_matrix & | dp | ||
) |
Computes the Gaussian form of the Legendre functions and the first derivatives.
Because there is no zero indexing in MATLAB, the P's are offset in the p matrix as follows:
n,m p(n+1,m+1) = P
MATLAB Form: [p, dP] = PGauss( nMax, mMax, theta )
------------------------------------------------------------------------ References: Wertz, J., Spacecraft Attitude Determination and Control, Kluwer, 1976, pp. 781.
nMax | max value of first index |
mMax | max value of second index |
theta | input value (usually an angle in rads) |
dp | Matrix for derivative outputs dp(n,m) / d(theta) |
void s_c_harm | ( | const ml_matrix & | a, |
int | n, | ||
ml_matrix & | s, | ||
ml_matrix & | c | ||
) |
Generate a series of sine and cosine harmonics.
a | Column vector (m,1) argument, in radians |
n | Number of harmonics |
s | Vector of sine harmonics output |
c | Vector of cosine harmonics output |
void c_to_d_zoh | ( | const ml_matrix & | a, |
const ml_matrix & | b, | ||
double | dT, | ||
ml_matrix & | f, | ||
ml_matrix & | g | ||
) |
Compute a discrete-time linear system from a continuous system.
a | Continuous matrix |
b | Continuous matrix |
dT | Time step (sec) |
f | Discrete matrix |
g | Discrete matrix |
ml_matrix expm | ( | const ml_matrix & | a ) |
a | Square matrix |
double WrapPhase | ( | double | angle ) |
ml_matrix WrapPhase | ( | ml_matrix | angle ) |
ml_matrix UnwrapPhase | ( | ml_matrix | angle ) |
ml_matrix diff | ( | ml_matrix | a ) |
Compute the difference between successive elements of a 1-D vector.
a | 1-dimensional matrix, length N |
ml_matrix delt_circ | ( | ml_matrix | x, |
ml_matrix | y | ||
) |
Compute a delta in circular coordinates.
It does not check dimensions.
x | 2-dimensional matrix |
y | 2-dimensional matrix |
References PI.
ml_matrix circle_fit | ( | ml_matrix | x, |
ml_matrix | y | ||
) |
Compute a delta in circular coordinates.
x | column matrix |
y | column matrix |
ml_matrix pinv | ( | ml_matrix | a ) |
Pseudo inverse.
a | matrix |
ml_matrix orthogonalize | ( | ml_matrix | a ) |
Orthogonalize.
Orthogonalize a 3x3 matrix
a | matrix |
ml_matrix logistic | ( | ml_matrix | x ) |
x | input |
double logistic | ( | double | x ) |
x | input |
double interp_extrap_1d | ( | ml_matrix | a, |
ml_matrix | x, | ||
double | xK | ||
) |
1D interpolation and extrapolation
a | array of values |
x | corresponding x value |
xK | value of interest |
double gaussian_multivariate_density | ( | ml_matrix | y, |
ml_matrix | y_bar, | ||
ml_matrix | P | ||
) |
Gaussian Mulivariate Normal Distribution function.
y | array of parameters |
y_bar | corresponding means |
P | covariance matrix |
ml_matrix roots_second_order | ( | double | a, |
double | b, | ||
double | c | ||
) |
Roots second order.
a | Coefficient |
b | Coefficient |
c | Coefficient |
ml_matrix roots_second_order | ( | const ml_matrix & | p ) |
Roots second order.
p | array of coefficients |
double trig_reduction | ( | double | a, |
double | b, | ||
double | c | ||
) |
a | Coefficient |
b | Coefficient |
c | RHS |