Mantid
|
Classes | |
struct | all_eig_symm_work |
workspace for subroutine allEigSymm More... | |
struct | evaluate_model_work |
workspace for subroutine evaluateModel More... | |
struct | get_svd_J_work |
workspace for subroutine getSvdJ More... | |
struct | max_eig_work |
workspace for subroutine max_eig More... | |
struct | min_eig_symm_work |
workspace for subroutine min_eig_work More... | |
struct | nlls_inform |
inform derived type with component defaults More... | |
struct | nlls_options |
struct | NLLS_workspace |
all workspaces called from the top level More... | |
struct | solve_general_work |
workspace for subroutine solve_general More... | |
struct | solve_LLS_work |
workspace for subroutine solve_LLS More... | |
Functions | |
void | allEigSymm (const DoubleFortranMatrix &A, DoubleFortranVector &ew, DoubleFortranMatrix &ev) |
Calculate all the eigenvalues of a symmetric matrix. More... | |
void | applyScaling (const DoubleFortranMatrix &J, DoubleFortranMatrix &A, DoubleFortranVector &v, DoubleFortranVector &scale, const nlls_options &options) |
Apply_scaling input Jacobian matrix, J ouput scaled Hessisan, H, and J^Tf, v. More... | |
double | calculateRho (double normf, double normfnew, double md, const nlls_options &options) |
Calculate the quantity 0.5||f||^2 - 0.5||fnew||^2 actual_reduction rho = -----------------------— = ----------------— m_k(0) - m_k(d) predicted_reduction. More... | |
double | dotProduct (const DoubleFortranVector &x, const DoubleFortranVector &y) |
Dot product of two vectors. More... | |
double | evaluateModel (const DoubleFortranVector &f, const DoubleFortranMatrix &J, const DoubleFortranMatrix &hf, const DoubleFortranVector &d, const nlls_options &options, evaluate_model_work &w) |
Input: f = f(x_k), J = J(x_k), hf = \sum_{i=1}^m f_i(x_k) \nabla^2 f_i(x_k) (or an approx) More... | |
void MANTID_CURVEFITTING_DLL | getSvdJ (const DoubleFortranMatrix &J, double &s1, double &sn) |
Given an (m x n) matrix J held by columns as a vector, this routine returns the largest and smallest singular values of J. More... | |
void MANTID_CURVEFITTING_DLL | matmultInner (const DoubleFortranMatrix &J, DoubleFortranMatrix &A) |
Takes an m x n matrix J and forms the n x n matrix A given by A = J' * J. More... | |
void MANTID_CURVEFITTING_DLL | multJ (const DoubleFortranMatrix &J, const DoubleFortranVector &x, DoubleFortranVector &Jx) |
Multiply a matrix by a vector. More... | |
void MANTID_CURVEFITTING_DLL | multJt (const DoubleFortranMatrix &J, const DoubleFortranVector &x, DoubleFortranVector &Jtx) |
Multiply a transposed matrix by a vector. More... | |
double MANTID_CURVEFITTING_DLL | norm2 (const DoubleFortranVector &v) |
Compute the 2-norm of a vector which is a square root of the sum of squares of its elements. More... | |
void | rankOneUpdate (DoubleFortranMatrix &hf, NLLS_workspace &w) |
Update the Hessian matrix without actually evaluating it (quasi-Newton?) More... | |
void | testConvergence (double normF, double normJF, double normF0, double normJF0, const nlls_options &options, nlls_inform &inform) |
Test the convergence. More... | |
void | updateTrustRegionRadius (double &rho, const nlls_options &options, NLLS_workspace &w) |
Update the trust region radius which is hidden in NLLS_workspace w (w.Delta). More... | |
Variables | |
const double | EPSILON_MCH = std::numeric_limits<double>::epsilon() |
Too small values don't work well with numerical derivatives. More... | |
void Mantid::CurveFitting::NLLS::allEigSymm | ( | const DoubleFortranMatrix & | A, |
DoubleFortranVector & | ew, | ||
DoubleFortranMatrix & | ev | ||
) |
Calculate all the eigenvalues of a symmetric matrix.
A | :: The input matrix. |
ew | :: The output eigenvalues. |
ev | :: The output eigenvectors. |
Definition at line 348 of file TrustRegion.cpp.
References Mantid::CurveFitting::EigenMatrix::eigenSystem().
Referenced by Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::calculateStep().
void Mantid::CurveFitting::NLLS::applyScaling | ( | const DoubleFortranMatrix & | J, |
DoubleFortranMatrix & | A, | ||
DoubleFortranVector & | v, | ||
DoubleFortranVector & | scale, | ||
const nlls_options & | options | ||
) |
Apply_scaling input Jacobian matrix, J ouput scaled Hessisan, H, and J^Tf, v.
Calculates a diagonal scaling W, stored in w.diag updates v(i) -> (1/W_i) * v(i) A(i,j) -> (1 / (W_i * W_j)) * A(i,j)
J | :: The Jacobian. |
A | :: The Hessian. |
v | :: The gradient (?). |
scale | :: Stored scaling data. |
options | :: The options. |
use the scaling present in gsl: scale by W, W_ii = ||J(i,:)||_2^2
scale using the (approximate) hessian
use the scaling present in gsl: scale by W, W_ii = ||J(i,:)||_2^2
scale using the (approximate) hessian
Definition at line 280 of file TrustRegion.cpp.
References Mantid::CurveFitting::FortranVector< VectorClass >::allocate(), Mantid::CurveFitting::FortranVector< VectorClass >::len(), Mantid::CurveFitting::FortranMatrix< MatrixClass >::len1(), Mantid::CurveFitting::FortranMatrix< MatrixClass >::len2(), Mantid::Geometry::m, n, Mantid::CurveFitting::NLLS::nlls_options::scale, Mantid::CurveFitting::NLLS::nlls_options::scale_max, Mantid::CurveFitting::NLLS::nlls_options::scale_min, Mantid::CurveFitting::NLLS::nlls_options::scale_require_increase, Mantid::CurveFitting::NLLS::nlls_options::scale_trim_max, and Mantid::CurveFitting::NLLS::nlls_options::scale_trim_min.
double Mantid::CurveFitting::NLLS::calculateRho | ( | double | normf, |
double | normfnew, | ||
double | md, | ||
const nlls_options & | options | ||
) |
Calculate the quantity 0.5||f||^2 - 0.5||fnew||^2 actual_reduction rho = -----------------------— = ----------------— m_k(0) - m_k(d) predicted_reduction.
if model is good, rho should be close to one
normf | :: The 2-norm of the residuals vector at d = 0. |
normfnew | :: The 2-norm of the residuals vector at d != 0. |
md | :: The value of the model at the same d as normfnew. |
options | :: The options. |
Definition at line 148 of file TrustRegion.cpp.
References EPSILON_MCH, fabs, rho, and UNUSED_ARG.
double Mantid::CurveFitting::NLLS::dotProduct | ( | const DoubleFortranVector & | x, |
const DoubleFortranVector & | y | ||
) |
Dot product of two vectors.
Definition at line 93 of file TrustRegion.cpp.
References Mantid::Geometry::x, and Mantid::Geometry::y.
Referenced by evaluateModel(), and rankOneUpdate().
double Mantid::CurveFitting::NLLS::evaluateModel | ( | const DoubleFortranVector & | f, |
const DoubleFortranMatrix & | J, | ||
const DoubleFortranMatrix & | hf, | ||
const DoubleFortranVector & | d, | ||
const nlls_options & | options, | ||
evaluate_model_work & | w | ||
) |
Input: f = f(x_k), J = J(x_k), hf = \sum_{i=1}^m f_i(x_k) \nabla^2 f_i(x_k) (or an approx)
We have a model m_k(d) = 0.5 f^T f + d^T J f + 0.5 d^T (J^T J + HF) d
This subroutine evaluates the model at the point d This value is returned as the scalar md :=m_k(d)
f | :: Vector of the residuals (at d = 0). |
J | :: The Jacobian matrix at d = 0. |
hf | :: The Hessian matrix at d = 0. |
d | :: The point where to evaluate the model. |
options | :: The options. |
w | :: The work struct. |
Definition at line 112 of file TrustRegion.cpp.
References Mantid::Geometry::d, dotProduct(), Mantid::CurveFitting::NLLS::evaluate_model_work::Hd, Mantid::CurveFitting::NLLS::evaluate_model_work::Jd, Mantid::CurveFitting::NLLS::evaluate_model_work::md_gn, Mantid::CurveFitting::NLLS::nlls_options::model, multJ(), and norm2().
void Mantid::CurveFitting::NLLS::getSvdJ | ( | const DoubleFortranMatrix & | J, |
double & | s1, | ||
double & | sn | ||
) |
Given an (m x n) matrix J held by columns as a vector, this routine returns the largest and smallest singular values of J.
J | :: The matrix. |
s1 | :: The largest sv. |
sn | :: The smalles sv. |
Definition at line 45 of file TrustRegion.cpp.
References Mantid::CurveFitting::EigenMatrix::inspector().
Referenced by Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::iterate().
void Mantid::CurveFitting::NLLS::matmultInner | ( | const DoubleFortranMatrix & | J, |
DoubleFortranMatrix & | A | ||
) |
Takes an m x n matrix J and forms the n x n matrix A given by A = J' * J.
J | :: The matrix. |
A | :: The result. |
Definition at line 31 of file TrustRegion.cpp.
References Mantid::CurveFitting::FortranMatrix< MatrixClass >::allocate(), Mantid::CurveFitting::EigenMatrix::inspector(), Mantid::CurveFitting::FortranMatrix< MatrixClass >::len2(), Mantid::CurveFitting::EigenMatrix::mutator(), and n.
Referenced by Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::calculateStep().
void Mantid::CurveFitting::NLLS::multJ | ( | const DoubleFortranMatrix & | J, |
const DoubleFortranVector & | x, | ||
DoubleFortranVector & | Jx | ||
) |
Multiply a matrix by a vector.
J | :: The matrix. |
x | :: The vector. |
Jx | :: The result vector. |
Definition at line 68 of file TrustRegion.cpp.
References Mantid::CurveFitting::FortranVector< VectorClass >::allocate(), Mantid::CurveFitting::EigenMatrix::inspector(), Mantid::CurveFitting::FortranVector< VectorClass >::len(), Mantid::CurveFitting::FortranMatrix< MatrixClass >::len1(), Mantid::CurveFitting::EigenVector::mutator(), and Mantid::Geometry::x.
Referenced by Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::calculateStep(), evaluateModel(), and rankOneUpdate().
void Mantid::CurveFitting::NLLS::multJt | ( | const DoubleFortranMatrix & | J, |
const DoubleFortranVector & | x, | ||
DoubleFortranVector & | Jtx | ||
) |
Multiply a transposed matrix by a vector.
J | :: The matrix. |
x | :: The vector. |
Jtx | :: The result vector. |
Definition at line 82 of file TrustRegion.cpp.
References Mantid::CurveFitting::FortranVector< VectorClass >::allocate(), Mantid::CurveFitting::EigenMatrix::inspector(), Mantid::CurveFitting::FortranVector< VectorClass >::len(), Mantid::CurveFitting::FortranMatrix< MatrixClass >::len2(), Mantid::CurveFitting::EigenVector::mutator(), and Mantid::Geometry::x.
Referenced by Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::calculateStep(), and Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::iterate().
double Mantid::CurveFitting::NLLS::norm2 | ( | const DoubleFortranVector & | v | ) |
Compute the 2-norm of a vector which is a square root of the sum of squares of its elements.
v | :: The vector. |
Definition at line 57 of file TrustRegion.cpp.
References Mantid::CurveFitting::EigenVector::norm(), and Mantid::CurveFitting::EigenVector::size().
Referenced by Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::calculateStep(), evaluateModel(), and Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::iterate().
void Mantid::CurveFitting::NLLS::rankOneUpdate | ( | DoubleFortranMatrix & | hf, |
NLLS_workspace & | w | ||
) |
Update the Hessian matrix without actually evaluating it (quasi-Newton?)
hf | :: The matrix to update. |
w | :: The work struct. |
safeguard: skip this update
safeguard: skip this update
Definition at line 167 of file TrustRegion.cpp.
References Mantid::CurveFitting::NLLS::NLLS_workspace::d, dotProduct(), EPSILON_MCH, fabs, Mantid::CurveFitting::NLLS::NLLS_workspace::hf, multJ(), Mantid::CurveFitting::EigenMatrix::mutator(), Mantid::CurveFitting::EigenVector::mutator(), Mantid::CurveFitting::NLLS::NLLS_workspace::Sks, Mantid::CurveFitting::NLLS::NLLS_workspace::y, Mantid::CurveFitting::NLLS::NLLS_workspace::y_sharp, and Mantid::CurveFitting::NLLS::NLLS_workspace::ysharpSks.
void Mantid::CurveFitting::NLLS::testConvergence | ( | double | normF, |
double | normJF, | ||
double | normF0, | ||
double | normJF0, | ||
const nlls_options & | options, | ||
nlls_inform & | inform | ||
) |
Test the convergence.
Definition at line 254 of file TrustRegion.cpp.
References Mantid::CurveFitting::NLLS::nlls_inform::convergence_normf, Mantid::CurveFitting::NLLS::nlls_inform::convergence_normg, Mantid::CurveFitting::NLLS::nlls_options::stop_g_absolute, and Mantid::CurveFitting::NLLS::nlls_options::stop_g_relative.
void Mantid::CurveFitting::NLLS::updateTrustRegionRadius | ( | double & | rho, |
const nlls_options & | options, | ||
NLLS_workspace & | w | ||
) |
Update the trust region radius which is hidden in NLLS_workspace w (w.Delta).
rho | :: The rho calculated by calculateRho(...). It may also be updated. |
options | :: The options. |
w | :: The work struct containing the radius that is to be updated (w.Delta). |
Definition at line 205 of file TrustRegion.cpp.
References Mantid::CurveFitting::NLLS::NLLS_workspace::Delta, Mantid::CurveFitting::NLLS::nlls_options::eta_success_but_reduce, Mantid::CurveFitting::NLLS::nlls_options::eta_successful, Mantid::CurveFitting::NLLS::nlls_options::eta_too_successful, Mantid::CurveFitting::NLLS::nlls_options::eta_very_successful, Mantid::CurveFitting::NLLS::nlls_options::maximum_radius, Mantid::CurveFitting::NLLS::NLLS_workspace::normd, Mantid::CurveFitting::NLLS::nlls_options::radius_increase, Mantid::CurveFitting::NLLS::nlls_options::radius_reduce, Mantid::CurveFitting::NLLS::nlls_options::radius_reduce_max, rho, Mantid::CurveFitting::NLLS::NLLS_workspace::tr_nu, Mantid::CurveFitting::NLLS::NLLS_workspace::tr_p, and Mantid::CurveFitting::NLLS::nlls_options::tr_update_strategy.
const double Mantid::CurveFitting::NLLS::EPSILON_MCH = std::numeric_limits<double>::epsilon() |
Too small values don't work well with numerical derivatives.
Definition at line 23 of file TrustRegion.cpp.
Referenced by calculateRho(), and rankOneUpdate().