Xmipp
v3.23.11-Nereus
|
Classes | |
class | GaussianInterpolator |
Functions | |
void | randomPermutation (int N, MultidimArray< int > &result) |
void | powellOptimizer (Matrix1D< double > &p, int i0, int n, double(*f)(double *, void *), void *prm, double ftol, double &fret, int &iter, const Matrix1D< double > &steps, bool show=false) |
double | solveNonNegative (const Matrix2D< double > &A, const Matrix1D< double > &b, Matrix1D< double > &result) |
void | solveViaCholesky (const Matrix2D< double > &A, const Matrix1D< double > &b, Matrix1D< double > &result) |
void | evaluateQuadratic (const Matrix1D< double > &x, const Matrix1D< double > &c, const Matrix2D< double > &H, double &val, Matrix1D< double > &grad) |
void | quadraticProgramming (const Matrix2D< double > &C, const Matrix1D< double > &d, const Matrix2D< double > &A, const Matrix1D< double > &b, const Matrix2D< double > &Aeq, const Matrix1D< double > &beq, Matrix1D< double > &bl, Matrix1D< double > &bu, Matrix1D< double > &x) |
void | leastSquare (const Matrix2D< double > &C, const Matrix1D< double > &d, const Matrix2D< double > &A, const Matrix1D< double > &b, const Matrix2D< double > &Aeq, const Matrix1D< double > &beq, Matrix1D< double > &bl, Matrix1D< double > &bu, Matrix1D< double > &x) |
void | regularizedLeastSquare (const Matrix2D< double > &A, const Matrix1D< double > &d, double lambda, const Matrix2D< double > &G, Matrix1D< double > &x) |
template<typename T > | |
void | solve (const Matrix2D< T > &A, const Matrix1D< T > &b, Matrix1D< T > &result) |
template<typename T > | |
void | solveBySVD (const Matrix2D< T > &A, const Matrix1D< T > &b, Matrix1D< double > &result, double tolerance) |
template<typename T > | |
void | solve (const Matrix2D< T > &A, const Matrix2D< T > &b, Matrix2D< T > &result) |
void evaluateQuadratic | ( | const Matrix1D< double > & | x, |
const Matrix1D< double > & | c, | ||
const Matrix2D< double > & | H, | ||
double & | val, | ||
Matrix1D< double > & | grad | ||
) |
Evaluate quadratic form
Given x, c and H this function returns the value of the quadratic form val=c^t*x+0.5*x^t*H^t*H*x and the gradient of the quadratic form at x grad=c+H*x.
Exceptions are thrown if the vectors and matrices do not have consistent dimensions.
Definition at line 126 of file numerical_tools.cpp.
void leastSquare | ( | const Matrix2D< double > & | C, |
const Matrix1D< double > & | d, | ||
const Matrix2D< double > & | A, | ||
const Matrix1D< double > & | b, | ||
const Matrix2D< double > & | Aeq, | ||
const Matrix1D< double > & | beq, | ||
Matrix1D< double > & | bl, | ||
Matrix1D< double > & | bu, | ||
Matrix1D< double > & | x | ||
) |
Solves the least square problem
Definition at line 322 of file numerical_tools.cpp.
void powellOptimizer | ( | Matrix1D< double > & | p, |
int | i0, | ||
int | n, | ||
double(*)(double *, void *) | f, | ||
void * | prm, | ||
double | ftol, | ||
double & | fret, | ||
int & | iter, | ||
const Matrix1D< double > & | steps, | ||
bool | show = false |
||
) |
Optimize using Powell's method.
See Numerical Recipes Chapter 10.
Problem: Minimize f(x) starting at point p. n is the dimension of x. If changes are smaller than ftol then stop. The number of iterations is returned in iter, fret contains the function value at the minimum and p contains the minimum.
Watch out that the evaluating function f must consider that x starts at index 1, at least, and goes until n. i0 is used to allow optimization in large spaces where only one part is going to be optimized. Thus, if in a vector of dimension 20 you want to optimize the first 3 components then i0=1, n=3; if you want to optimize it all, i0=1, n=20; and if you want to optimize the last five components i0=15, n=5.
The steps define the allowed steps on each variable. When a variable has large ranges this step should be larger to allow bigger movements. The steps should have only the dimension of the optimized part (3,20 and 5 in the examples above).
The option show forces the routine to show the convergence path
If your function needs extra parameters you can pass them through the void pointer prm. If you don't need this feature set it to NULL.
Example of use:
void quadraticProgramming | ( | const Matrix2D< double > & | C, |
const Matrix1D< double > & | d, | ||
const Matrix2D< double > & | A, | ||
const Matrix1D< double > & | b, | ||
const Matrix2D< double > & | Aeq, | ||
const Matrix1D< double > & | beq, | ||
Matrix1D< double > & | bl, | ||
Matrix1D< double > & | bu, | ||
Matrix1D< double > & | x | ||
) |
Solves Quadratic programming subproblem
Definition at line 222 of file numerical_tools.cpp.
void randomPermutation | ( | int | N, |
MultidimArray< int > & | result | ||
) |
Generate random permutation
Generate a random permutation of the numbers between 0 and N-1
Definition at line 33 of file numerical_tools.cpp.
void regularizedLeastSquare | ( | const Matrix2D< double > & | A, |
const Matrix1D< double > & | d, | ||
double | lambda, | ||
const Matrix2D< double > & | G, | ||
Matrix1D< double > & | x | ||
) |
Solves the regularized least squares problem
Give an empty G matrix (NULL matrix) if G is the identity matrix If AtA is not a NULL matrix, then the product AtA is not computed.
Definition at line 342 of file numerical_tools.cpp.
void solve | ( | const Matrix2D< T > & | A, |
const Matrix1D< T > & | b, | ||
Matrix1D< T > & | result | ||
) |
Solves a linear equation system by LU decomposition.
Definition at line 215 of file numerical_tools.h.
void solve | ( | const Matrix2D< T > & | A, |
const Matrix2D< T > & | b, | ||
Matrix2D< T > & | result | ||
) |
Solves a linear equation system by Gaussian elimination.
Definition at line 2218 of file numerical_tools.cpp.
void solveBySVD | ( | const Matrix2D< T > & | A, |
const Matrix1D< T > & | b, | ||
Matrix1D< double > & | result, | ||
double | tolerance | ||
) |
Solves a linear equation system by SVD decomposition.
Definition at line 2179 of file numerical_tools.cpp.
double solveNonNegative | ( | const Matrix2D< double > & | A, |
const Matrix1D< double > & | b, | ||
Matrix1D< double > & | result | ||
) |
Solve equation system, nonnegative solution
The equation system is defined by Ax=b, it is solved for x. x is forced to be nonnegative. It is designed to cope with large equation systems. This function is borrowed from LAPACK nnls.
The norm of the vector Ax-b is returned.
Definition at line 82 of file numerical_tools.cpp.
void solveViaCholesky | ( | const Matrix2D< double > & | A, |
const Matrix1D< double > & | b, | ||
Matrix1D< double > & | result | ||
) |
Solve equation system, symmetric positive-definite matrix
The equation system is defined by Ax=b, it is solved for x. This method can only be applied if A is positive-definite matrix and symmetric. It applies a Cholesky factorization and backsubstitution (see Numerical Recipes).
Definition at line 111 of file numerical_tools.cpp.