ANIMA  4.0
animaNNLSOptimizer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vnl/vnl_matrix.h>
4 #include <vector>
5 
6 #include <itkOptimizer.h>
7 
9 #include "AnimaOptimizersExport.h"
10 
11 namespace anima
12 {
19 class ANIMAOPTIMIZERS_EXPORT NNLSOptimizer : public itk::Optimizer
20 {
21 public:
25  typedef itk::SmartPointer<Self> Pointer;
26  typedef itk::SmartPointer<const Self> ConstPointer;
27 
28  typedef Superclass::ParametersType ParametersType;
29 
31  itkNewMacro(Self)
32 
33 
34  itkTypeMacro(NNLSOptimizer, Optimizer)
35 
36 
37  typedef vnl_matrix <double> MatrixType;
38  typedef vnl_vector <double> VectorType;
39 
41  void StartOptimization() ITK_OVERRIDE;
42 
43  void SetDataMatrix(const MatrixType &data) {m_DataMatrix = data;}
44  void SetPoints(const ParametersType &points) {m_Points = points;}
45 
46  double GetCurrentResidual();
47 
48  itkSetMacro(SquaredProblem, bool)
49 
50 protected:
52  {
53  m_SquaredProblem = false;
54  }
55 
56  virtual ~NNLSOptimizer() ITK_OVERRIDE {}
57 
58 private:
59  ITK_DISALLOW_COPY_AND_ASSIGN(NNLSOptimizer);
60 
61  unsigned int UpdateProcessedIndexes();
62  void ComputeSPVector();
63  void ComputeWVector();
64 
65  MatrixType m_DataMatrix;
66  ParametersType m_Points;
67 
68  static const double m_EpsilonValue;
69 
71  bool m_SquaredProblem;
72 
73  // Working values
74  std::vector <unsigned short> m_TreatedIndexes;
75  std::vector <unsigned int> m_ProcessedIndexes;
76  std::vector <double> m_WVector;
77  VectorType m_SPVector;
78  MatrixType m_DataMatrixP;
79 
80  anima::CholeskyDecomposition m_CholeskySolver;
81 };
82 
83 } // end of namespace anima
itk::SmartPointer< Self > Pointer
vnl_matrix< double > MatrixType
itk::SmartPointer< const Self > ConstPointer
Superclass::ParametersType ParametersType
void SetPoints(const ParametersType &points)
itk::Optimizer Superclass
vnl_vector< double > VectorType
virtual ~NNLSOptimizer() ITK_OVERRIDE
Non negative least squares optimizer. Implements Lawson et al method, of squared problem is activated...
Cholesky decomposition: decomposes a symmetric matrix A in the form L D L^T, where L is lower triangu...