ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkConjugateGradientOptimizer.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkConjugateGradientOptimizer_h
00019 #define __itkConjugateGradientOptimizer_h
00020 
00021 #include "itkIntTypes.h"
00022 #include "itkSingleValuedNonLinearVnlOptimizer.h"
00023 #include "vnl/algo/vnl_conjugate_gradient.h"
00024 
00025 namespace itk
00026 {
00033 class ITK_EXPORT ConjugateGradientOptimizer:
00034   public SingleValuedNonLinearVnlOptimizer
00035 
00036 {
00037 public:
00039   typedef ConjugateGradientOptimizer        Self;
00040   typedef SingleValuedNonLinearVnlOptimizer Superclass;
00041   typedef SmartPointer< Self >              Pointer;
00042   typedef SmartPointer< const Self >        ConstPointer;
00043 
00045   itkNewMacro(Self);
00046 
00048   itkTypeMacro(ConjugateGradientOptimizer, SingleValuedNonLinearOptimizer);
00049 
00051   typedef   vnl_vector< double > InternalParametersType;
00052 
00054   typedef   vnl_conjugate_gradient InternalOptimizerType;
00055 
00057   vnl_conjugate_gradient * GetOptimizer(void);
00058 
00060   void StartOptimization(void);
00061 
00063   virtual void SetCostFunction(SingleValuedCostFunction *costFunction);
00064 
00066   SizeValueType GetNumberOfIterations(void) const;
00067 
00068   SizeValueType GetCurrentIteration(void) const;
00069 
00071   MeasureType GetValue() const;
00072 
00073 protected:
00074   ConjugateGradientOptimizer();
00075   virtual ~ConjugateGradientOptimizer();
00076 
00077   typedef Superclass::CostFunctionAdaptorType CostFunctionAdaptorType;
00078 private:
00079   ConjugateGradientOptimizer(const Self &); //purposely not implemented
00080   void operator=(const Self &);             //purposely not implemented
00081 
00083   bool                   m_OptimizerInitialized;
00084   InternalOptimizerType *m_VnlOptimizer;
00085 };
00086 } // end namespace itk
00087 
00088 #endif
00089