ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkSingleValuedVnlCostFunctionAdaptor.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkSingleValuedVnlCostFunctionAdaptor_h
19 #define __itkSingleValuedVnlCostFunctionAdaptor_h
20 
22 #include "vnl/vnl_cost_function.h"
23 
24 namespace itk
25 {
37  public vnl_cost_function
38 {
39 public:
40 
42  typedef vnl_vector< double > InternalParametersType;
43 
45  typedef double InternalMeasureType;
46 
48  typedef vnl_vector< double > InternalDerivativeType;
49 
52 
55 
58 
61 
63  SingleValuedVnlCostFunctionAdaptor(unsigned int spaceDimension);
64 
67  { m_CostFunction = costFunction; }
68 
71  { return m_CostFunction; }
72 
74  virtual InternalMeasureType f(const InternalParametersType & inparameters) ITK_OVERRIDE;
75 
77  virtual void gradf(const InternalParametersType & inparameters,
78  InternalDerivativeType & gradient) ITK_OVERRIDE;
79 
81  virtual void compute(const InternalParametersType & x,
83  InternalDerivativeType *g) ITK_OVERRIDE;
84 
87  const DerivativeType & input,
88  InternalDerivativeType & output) const;
89 
91  void SetScales(const ScalesType & scales);
92 
101  void SetNegateCostFunction(bool value);
102 
103  bool GetNegateCostFunction() const;
104 
107 
112  unsigned long AddObserver(const EventObject & event, Command *) const;
113 
118  const MeasureType & GetCachedValue() const;
119 
120  const DerivativeType & GetCachedDerivative() const;
121 
123 
124 protected:
125 
128  void ReportIteration(const EventObject & event) const;
129 
130 private:
131 
133  itkGetConstReferenceMacro(InverseScales, ScalesType);
134 
140 
144 }; // end of Class CostFunction
145 } // end namespace itk
146 
147 #endif
const MeasureType & GetCachedValue() const
Array class with size defined at construction time.
Definition: itkArray.h:50
SingleValuedCostFunction::DerivativeType DerivativeType
unsigned long AddObserver(const EventObject &event, Command *) const
This class is a base for the CostFunctions returning a single value.
void ReportIteration(const EventObject &event) const
This class is an Adaptor that allows to pass itk::SingleValuedCostFunctions to vnl_optimizers expecti...
const DerivativeType & GetCachedDerivative() const
SingleValuedCostFunction::ParametersType ParametersType
SingleValuedVnlCostFunctionAdaptor(unsigned int spaceDimension)
void SetCostFunction(SingleValuedCostFunction *costFunction)
Abstraction of the Events used to communicating among filters and with GUIs.
virtual void gradf(const InternalParametersType &inparameters, InternalDerivativeType &gradient) ITK_OVERRIDE
const ParametersType & GetCachedCurrentParameters() const
void ConvertExternalToInternalGradient(const DerivativeType &input, InternalDerivativeType &output) const
const SingleValuedCostFunction * GetCostFunction(void) const
virtual void compute(const InternalParametersType &x, InternalMeasureType *f, InternalDerivativeType *g) ITK_OVERRIDE
void SetScales(const ScalesType &scales)
virtual InternalMeasureType f(const InternalParametersType &inparameters) ITK_OVERRIDE
Superclass for callback/observer methods.
Definition: itkCommand.h:44