DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkSolverBase.hxx
Go to the documentation of this file.
1 
20 #ifndef __itkSolverBase_hxx
21 #define __itkSolverBase_hxx
22 
23 #include "itkSolverBase.h"
24 #include "utl.h"
25 
26 
27 namespace itk
28 {
29 
30 //---------------------------------------------------------
31 template <class TPrecision>
34 {
35 }
36 
37 template < class TPrecision >
38 void
40 ::Solve ( const VectorType& xInitial)
41 {
42  this->VerifyInputs();
43 }
44 
45 template < class TPrecision >
46 void
48 ::Initialize ( const VectorType& xInitial)
49 {
50  int N = GetXDimension();
51 
52  if (xInitial.Size()==0)
53  {
54  m_x.ReSize(N);
55  m_x.Fill(0.0);
56  }
57  else
58  {
59  utlException(xInitial.Size()!=N, "wrong size of xInitial. xInitial.Size()="<<xInitial.Size());
60  m_x = xInitial;
61  }
62 }
63 
64 template < class TPrecision >
65 void
67 ::Clear ( )
68 {
69  m_x.Clear();
70 }
71 
72 template < class TPrecision >
73 typename LightObject::Pointer
76 {
77  typename LightObject::Pointer loPtr = Superclass::InternalClone();
78 
79  typename Self::Pointer rval = dynamic_cast<Self *>(loPtr.GetPointer());
80  if(rval.IsNull())
81  {
82  itkExceptionMacro(<< "downcast to type " << this->GetNameOfClass()<< " failed.");
83  }
84  rval->m_x = m_x;
85  rval->SetDebug(this->GetDebug());
86  return loPtr;
87 }
88 
89 template <class TPrecision>
90 void
92 ::PrintSelf(std::ostream& os, Indent indent) const
93 {
94  Superclass::PrintSelf(os, indent);
95  utl::PrintUtlVector(this->m_x, "m_x", " ", os << indent);
96 }
97 
98 } // end namespace itk
99 
100 #endif
101 
helper functions specifically used in dmritool
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
virtual void Initialize(const VectorType &xInitial=VectorType())
virtual LightObject::Pointer InternalClone() const ITK_OVERRIDE
#define utlException(cond, expout)
Definition: utlCoreMacro.h:548
virtual void Solve(const VectorType &xInitial=VectorType())
virtual void Clear()
SmartPointer< Self > Pointer
Definition: itkSolverBase.h:45
void PrintUtlVector(const NDArray< T, 1 > &vec, const std::string &str="", const char *separate=" ", std::ostream &os=std::cout, bool showStats=true)
SizeType Size() const
Definition: utlNDArray.h:321
Base class for some optimization solvers using primal-dual updates.
Definition: itkSolverBase.h:39