FunctionalAdaptor.hpp

00001 // This file is part of the imaging2 class library.
00002 //
00003 // University of Innsbruck, Infmath Imaging, 2009.
00004 // http://infmath.uibk.ac.at
00005 //
00006 // All rights reserved.
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

Generated on Tue Feb 10 10:01:30 2009 for imaging2 by  doxygen 1.5.5