ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkMultipleValuedVnlCostFunctionAdaptor.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 __itkMultipleValuedVnlCostFunctionAdaptor_h
19 #define __itkMultipleValuedVnlCostFunctionAdaptor_h
20 
22 #include "vnl/vnl_least_squares_function.h"
23 
24 namespace itk
25 {
37  public vnl_least_squares_function
38 {
39 public:
40 
43 
46 
49 
52 
55 
58 
61 
63  MultipleValuedVnlCostFunctionAdaptor(unsigned int spaceDimension,
64  unsigned int numberOfValues);
65 
67  void SetCostFunction(MultipleValuedCostFunction *costFunction)
68  { m_CostFunction = costFunction; }
69 
71  const MultipleValuedCostFunction * GetCostFunction(void) const
72  { return m_CostFunction; }
73 
75  virtual void f(const InternalParametersType & inparameters,
76  InternalMeasureType & measures);
77 
79  virtual void gradf(const InternalParametersType & inparameters,
80  InternalDerivativeType & gradient);
81 
83  virtual void compute(const InternalParametersType & x,
84  InternalMeasureType *f,
85  InternalDerivativeType *g);
86 
88  void ConvertExternalToInternalGradient(
89  const DerivativeType & input,
90  InternalDerivativeType & output);
91 
93  void ConvertExternalToInternalMeasures(
94  const MeasureType & input,
95  InternalMeasureType & output);
96 
100  void SetUseGradient(bool);
101 
102  void UseGradientOn() { this->SetUseGradient(true); }
103  void UseGradientOff() { this->SetUseGradient(false); }
104  bool GetUseGradient() const;
105 
107  void SetScales(const ScalesType & scales);
108 
113  unsigned long AddObserver(const EventObject & event, Command *) const;
114 
119  const MeasureType & GetCachedValue() const;
120 
121  const DerivativeType & GetCachedDerivative() const;
122 
123  const ParametersType & GetCachedCurrentParameters() const;
124 
125 protected:
126 
129  void ReportIteration(const EventObject & event) const;
130 
131 private:
132 
134 
138 
142 }; // end of Class CostFunction
143 } // end namespace itk
144 
145 #endif
146