DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkSolverBase.h
Go to the documentation of this file.
1 
18 #ifndef __itkSolverBase_h
19 #define __itkSolverBase_h
20 
21 #include <itkObject.h>
22 #include <itkObjectFactory.h>
23 #include "vnl/vnl_matrix.h"
24 #include "utlSTDHeaders.h"
25 #include "utlNDArray.h"
26 
27 
28 namespace itk
29 {
30 
38 template <class TPrecision>
39 class ITK_EXPORT SolverBase : public Object
40 {
41 public:
43  typedef SolverBase Self;
44  typedef Object Superclass;
45  typedef SmartPointer<Self> Pointer;
46 
48  itkNewMacro(Self);
49 
51  itkTypeMacro(SolverBase, Object);
52 
53  typedef TPrecision ValueType;
56  typedef utl_shared_ptr<MatrixType> MatrixPointer;
57  typedef utl_shared_ptr<VectorType> VectorPointer;
58  typedef std::vector<ValueType> ValueContainerType;
59  typedef utl_shared_ptr<std::vector<ValueType> > ValueContainerPointer;
60 
61  virtual int GetXDimension() const
62  {return 0;}
63  itkGetConstReferenceMacro(x, VectorType);
64 
65  virtual void VerifyInputs() const {}
66  virtual void Initialize(const VectorType& xInitial=VectorType());
67  virtual void EndSolve() {}
68 
70  virtual ValueType EvaluateCostFunction(const VectorType& x=VectorType()) const {return ValueType(0.0);}
71  virtual ValueType EvaluateCostFunction(const MatrixType& x=MatrixType()) const {return ValueType(0.0);}
73  virtual VectorType EvaluateGradientOfCostFunction(const VectorType& x) const {return VectorType(); }
74 
75  virtual void Solve(const VectorType& xInitial=VectorType());
76 
77  virtual void Solve(const MatrixType& xInitial=MatrixType())
78  {
79  this->VerifyInputs();
80  }
81 
82  virtual void Clear();
83 
84 protected:
85  SolverBase();
86  virtual ~SolverBase() {};
87 
88  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
89 
90  virtual typename LightObject::Pointer InternalClone() const ITK_OVERRIDE;
91 
93  VectorType m_x;
94 
95 private:
96  SolverBase(const Self&); //purposely not implemented
97  void operator=(const Self&); //purposely not implemented
98 
99 };
100 
101 }
102 
103 // Define instantiation macro for this template.
104 #define ITK_TEMPLATE_SolverBase(_, EXPORT, TypeX, TypeY) \
105  namespace itk \
106  { \
107  _( 1 ( class EXPORT SolverBase< ITK_TEMPLATE_1 TypeX > ) ) \
108  namespace Templates \
109  { \
110  typedef SolverBase< ITK_TEMPLATE_1 TypeX > SolverBase##TypeY; \
111  } \
112  }
113 
114 #if ITK_TEMPLATE_EXPLICIT
115 #include "Templates/itkSolverBase+-.h"
116 #endif
117 
118 #if !defined(ITK_MANUAL_INSTANTIATION) && !defined(__itkSolverBase_hxx)
119 #include "itkSolverBase.hxx"
120 #endif
121 
122 #endif
NDArray is a N-Dimensional array class (row-major, c version)
Definition: utlFunctors.h:131
TPrecision ValueType
Definition: itkSolverBase.h:51
virtual void Solve(const MatrixType &xInitial=MatrixType())
Definition: itkSolverBase.h:77
SolverBase Self
Definition: itkSolverBase.h:43
virtual VectorType EvaluateGradientOfCostFunction(const VectorType &x) const
Definition: itkSolverBase.h:73
#define ITK_OVERRIDE
Definition: utlITKMacro.h:46
VectorType m_x
Definition: itkSolverBase.h:93
virtual ValueType EvaluateCostFunction(const VectorType &x=VectorType()) const
Definition: itkSolverBase.h:70
SmartPointer< Self > Pointer
Definition: itkSolverBase.h:45
virtual ValueType EvaluateCostFunction(const MatrixType &x=MatrixType()) const
Definition: itkSolverBase.h:71
virtual void VerifyInputs() const
Definition: itkSolverBase.h:65
virtual ~SolverBase()
Definition: itkSolverBase.h:86
utl_shared_ptr< VectorType > VectorPointer
Definition: itkSolverBase.h:57
utl_shared_ptr< MatrixType > MatrixPointer
Definition: itkSolverBase.h:56
virtual int GetXDimension() const
Definition: itkSolverBase.h:61
utl::NDArray< ValueType, 1 > VectorType
Definition: itkSolverBase.h:55
virtual void EndSolve()
Definition: itkSolverBase.h:67
utl::NDArray< ValueType, 2 > MatrixType
Definition: itkSolverBase.h:54
Base class for some optimization solvers using primal-dual updates.
Definition: itkSolverBase.h:39
std::vector< ValueType > ValueContainerType
Definition: itkSolverBase.h:58
utl_shared_ptr< std::vector< ValueType > > ValueContainerPointer
Definition: itkSolverBase.h:59