| DiSMEC++
    | 
Approximately solve a linear equation Ax + b = 0.  
 More...
#include <cg.h>
 
  
| Public Types | |
| using | MatrixVectorProductFn = std::function< void(const DenseRealVector &, Eigen::Ref< DenseRealVector >)> | 
|  Public Types inherited from dismec::HyperParameterBase | |
| using | hyper_param_t = std::variant< long, double > | 
| Public Member Functions | |
| CGMinimizer (long num_vars) | |
| long | minimize (const MatrixVectorProductFn &A, const DenseRealVector &b, const DenseRealVector &M) | 
| Solves Ax+b=0. returns the number of iterations.  More... | |
| const DenseRealVector & | get_solution () const | 
| returns the solution vector found by the last minimize call  More... | |
| double | get_epsilon () const | 
| Gets the value of the tolerance hyperparameter.  More... | |
| void | set_epsilon (double v) | 
| Sets the value of the tolerance hyperparameter.  More... | |
|  Public Member Functions inherited from dismec::HyperParameterBase | |
| HyperParameterBase ()=default | |
| virtual | ~HyperParameterBase ()=default | 
| HyperParameterBase (const HyperParameterBase &)=default | |
| HyperParameterBase (HyperParameterBase &&)=default | |
| HyperParameterBase & | operator= (HyperParameterBase &&)=default | 
| HyperParameterBase & | operator= (const HyperParameterBase &)=default | 
| void | set_hyper_parameter (const std::string &name, long value) | 
| void | set_hyper_parameter (const std::string &name, double value) | 
| hyper_param_t | get_hyper_parameter (const std::string &name) const | 
| std::vector< std::string > | get_hyper_parameter_names () const | 
| Returns a vector that lists all hyper parameter names.  More... | |
| Private Member Functions | |
| long | do_minimize (const MatrixVectorProductFn &A, const DenseRealVector &b, const DenseRealVector &M) | 
| Private Attributes | |
| long | m_Size | 
| real_t | m_Epsilon = CG_DEFAULT_EPSILON | 
| DenseRealVector | m_A_times_d | 
| DenseRealVector | m_S | 
| s from the CG algorithm  More... | |
| DenseRealVector | m_Residual | 
| r_k from the CG algorithm  More... | |
| DenseRealVector | m_Conjugate | 
| p_k from the CG algorithm  More... | |
| Additional Inherited Members | |
|  Protected Member Functions inherited from dismec::HyperParameterBase | |
| template<class U , class S > | |
| void | declare_hyper_parameter (std::string name, U S::*pointer) | 
| template<class U , class S > | |
| void | declare_hyper_parameter (std::string name, U(S::*getter)() const, void(S::*setter)(U)) | 
| Declares an constrained hyper-parameter with explicit getter and setter function.  More... | |
| template<class T , class S > | |
| void | declare_sub_object (const std::string &name, T S::*object) | 
| Declares a sub-object that also contains hyper-parameters.  More... | |
Approximately solve a linear equation Ax + b = 0. 
This class uses a CG algorithm to approximately solve Ax + b = 0. It does not require the entire matrix A but only a function that allows to calculate Ad for an arbitrary vector d. This class has a size of approximately 5n sizeof(double) for n being the number of variables. 
| using dismec::solvers::CGMinimizer::MatrixVectorProductFn = std::function<void(const DenseRealVector &, Eigen::Ref<DenseRealVector>)> | 
| 
 | explicit | 
Definition at line 12 of file cg.cpp.
References dismec::HyperParameterBase::declare_hyper_parameter(), get_epsilon(), m_A_times_d, m_Conjugate, m_Residual, m_S, and set_epsilon().
| 
 | private | 
Definition at line 26 of file cg.cpp.
References dismec::CG_MIN_ITER_BOUND, m_A_times_d, m_Conjugate, m_Epsilon, m_Residual, m_S, and m_Size.
Referenced by minimize().
| 
 | inline | 
Gets the value of the tolerance hyperparameter.
Definition at line 38 of file cg.h.
References m_Epsilon.
Referenced by CGMinimizer().
| 
 | inline | 
returns the solution vector found by the last minimize call
Definition at line 35 of file cg.h.
References m_S.
Referenced by dismec::solvers::NewtonWithLineSearch::run().
| long CGMinimizer::minimize | ( | const MatrixVectorProductFn & | A, | 
| const DenseRealVector & | b, | ||
| const DenseRealVector & | M | ||
| ) | 
Solves Ax+b=0. returns the number of iterations. 
Definition at line 21 of file cg.cpp.
References do_minimize().
Referenced by dismec::solvers::NewtonWithLineSearch::run().
| 
 | inline | 
Sets the value of the tolerance hyperparameter.
Definition at line 41 of file cg.h.
References m_Epsilon.
Referenced by CGMinimizer().
| 
 | private | 
Definition at line 50 of file cg.h.
Referenced by CGMinimizer(), and do_minimize().
| 
 | private | 
p_k from the CG algorithm
Definition at line 53 of file cg.h.
Referenced by CGMinimizer(), and do_minimize().
| 
 | private | 
Definition at line 47 of file cg.h.
Referenced by do_minimize(), get_epsilon(), and set_epsilon().
| 
 | private | 
r_k from the CG algorithm
Definition at line 52 of file cg.h.
Referenced by CGMinimizer(), and do_minimize().
| 
 | private | 
s from the CG algorithm
Definition at line 51 of file cg.h.
Referenced by CGMinimizer(), do_minimize(), and get_solution().
| 
 | private | 
Definition at line 46 of file cg.h.
Referenced by do_minimize().