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