Skip to content
Snippets Groups Projects
ConnectionFunctionIdentity.cpp 1.08 KiB
/**
 * DESCRIPTION OF THE FILE
 *
 * @author Michal Kravčenko
 * @date 14.6.18 -
 */

#include <boost/serialization/export.hpp>

#include "ConnectionFunctionIdentity.h"
#include "ConnectionFunctionIdentitySerialization.h"
#include "ConnectionFunctionGeneralSerialization.h"

BOOST_CLASS_EXPORT_IMPLEMENT(ConnectionFunctionIdentity);

ConnectionFunctionIdentity::ConnectionFunctionIdentity() {
    this->is_unitary = true;
}

ConnectionFunctionIdentity::ConnectionFunctionIdentity(size_t pidx) {
    this->param_idx  = pidx;
    this->is_unitary = false;
}

double ConnectionFunctionIdentity::eval(std::vector<double>& parameter_space) {

    if (this->is_unitary) {
        return 1.0;
    }

    return parameter_space.at(this->param_idx);
}

void ConnectionFunctionIdentity::eval_partial_derivative(std::vector<double>& parameter_space,
                                                         std::vector<double>& weight_gradient,
                                                         double alpha) {

    if (this->is_unitary) {
        return;
    }

    weight_gradient[this->param_idx] += alpha;
}