Mantid
Loading...
Searching...
No Matches
Classes | Functions | Variables
Mantid::CurveFitting::NLLS Namespace Reference

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

Function Documentation

◆ allEigSymm()

void Mantid::CurveFitting::NLLS::allEigSymm ( const DoubleFortranMatrix A,
DoubleFortranVector ew,
DoubleFortranMatrix ev 
)

Calculate all the eigenvalues of a symmetric matrix.

Parameters
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().

◆ applyScaling()

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)

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

◆ calculateRho()

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

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

◆ dotProduct()

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().

◆ evaluateModel()

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)

Parameters
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().

◆ getSvdJ()

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.

Parameters
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().

◆ matmultInner()

void Mantid::CurveFitting::NLLS::matmultInner ( const DoubleFortranMatrix J,
DoubleFortranMatrix A 
)

◆ multJ()

void Mantid::CurveFitting::NLLS::multJ ( const DoubleFortranMatrix J,
const DoubleFortranVector x,
DoubleFortranVector Jx 
)

◆ multJt()

void Mantid::CurveFitting::NLLS::multJt ( const DoubleFortranMatrix J,
const DoubleFortranVector x,
DoubleFortranVector Jtx 
)

◆ norm2()

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.

Parameters
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().

◆ rankOneUpdate()

void Mantid::CurveFitting::NLLS::rankOneUpdate ( DoubleFortranMatrix hf,
NLLS_workspace w 
)

◆ testConvergence()

void Mantid::CurveFitting::NLLS::testConvergence ( double  normF,
double  normJF,
double  normF0,
double  normJF0,
const nlls_options options,
nlls_inform inform 
)

◆ updateTrustRegionRadius()

void Mantid::CurveFitting::NLLS::updateTrustRegionRadius ( double &  rho,
const nlls_options options,
NLLS_workspace w 
)

Variable Documentation

◆ EPSILON_MCH

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().