00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef MINIMIZE_DIFFERENTIABLEFUNCTIONALADAPTOR_H
00010 #define MINIMIZE_DIFFERENTIABLEFUNCTIONALADAPTOR_H
00011
00012 #include <minimize/FunctionalAdaptor.hpp>
00013 #include <minimize/DifferentiableEnergyInterface.hpp>
00014
00015 namespace imaging
00016 {
00020 template <class functional_t>
00021 class DifferentiableFunctionalAdaptor : public DifferentiableEnergyInterface
00022 {
00023 FunctionalAdaptor<functional_t> _functional_adaptor;
00024 ublas::vector<float_t> _current_gradient;
00025
00026 public:
00027 DifferentiableFunctionalAdaptor(functional_t & functional) :
00028 _functional_adaptor(functional),
00029 _current_gradient(functional.dimension())
00030 {}
00031
00032 ublas::vector<float_t> & current_argument()
00033 {
00034 return _functional_adaptor.current_argument();
00035 }
00036
00037 void set_argument()
00038 {
00039 _functional_adaptor.set_argument();
00040 }
00041
00042 void set_argument_with_gradient()
00043 {
00044 _functional_adaptor._current_energy = _functional_adaptor._functional(_functional_adaptor._current_argument, _current_gradient);
00045 }
00046
00047 float_t current_energy() const
00048 {
00049 return _functional_adaptor.current_energy();
00050 }
00051
00052 std::size_t dimension() const
00053 {
00054 return _functional_adaptor.dimension();
00055 }
00056
00057 const ublas::vector<float_t> & current_gradient() const
00058 {
00059 return _current_gradient;
00060 }
00061 };
00062 }
00063
00064 #endif