https://github.com/ElsevierSoftwareX/SOFTX_2019_219
Revision cc7055c78202813215e6c607255bdfdf6e088dca authored by Konrad Werys on 01 November 2019, 12:51:09 UTC, committed by Konrad Werys on 01 November 2019, 12:51:09 UTC
1 parent 00b20ae
Raw File
Tip revision: cc7055c78202813215e6c607255bdfdf6e088dca authored by Konrad Werys on 01 November 2019, 12:51:09 UTC
ci: big changes to the builds v13
Tip revision: cc7055c
OxFunctionsT1AdapterVnlCost.h
/*!
 * \file OxFunctionsT1AdapterVnlCost.h
 * \author Konrad Werys
 * \date 2018/07/30
 */

#ifndef Tomato_OXFUNCTIONST1ADAPTERVNLCOST_H
#define Tomato_OXFUNCTIONST1ADAPTERVNLCOST_H

#include "CmakeConfigForTomato.h"
#ifdef USE_VNL

#include <vnl/vnl_cost_function.h>

#include "OxFunctionsT1.h"

namespace Ox {

    class FunctionsT1AdapterVnlCost : public vnl_cost_function {

    public:

        // cost function problem formulation
        double f(vnl_vector<double> const& params){ // override
            //_FunctionsT1->copyToParameters(params.data_block());
            return _FunctionsT1->calcCostValue(params.data_block());
        }

        // cost function gradient
        void gradf (vnl_vector< double > const &params, vnl_vector< double > &gradient){ // override

            //_FunctionsT1->copyToParameters(params.data_block());
            _FunctionsT1->calcCostDerivative(params.data_block(), gradient.data_block());
        }

        void setFunctionsT1(FunctionsT1<double>* _FunctionsT1){
            this->_FunctionsT1 = _FunctionsT1;
        };

        // getters
        FunctionsT1<double>* getFunctionsT1(){
            return _FunctionsT1;
        };

        /**
         * constructor
         */
        FunctionsT1AdapterVnlCost(int nDims) : vnl_cost_function(nDims){
            _FunctionsT1 = 0; // nullpointer
        };

        /**
         * copy constructor
         * @param old
         */
        FunctionsT1AdapterVnlCost(const FunctionsT1AdapterVnlCost &old){
            _FunctionsT1 = old._FunctionsT1;
        }

    private:

        FunctionsT1<double>* _FunctionsT1;
    };

} // namespace Ox

#endif //USE_VNL

#endif //Tomato_OXFUNCTIONST1ADAPTERVNLCOST_H
back to top