Skip to content
Snippets Groups Projects
ConnectionFunctionGeneral.cpp 1.35 KiB
Newer Older
  • Learn to ignore specific revisions
  • /**
     * DESCRIPTION OF THE FILE
     *
     * @author Michal Kravčenko
     * @date 14.6.18 -
     */
    
    
    #include "ConnectionWeight.h"
    
    ConnectionWeight::ConnectionWeight() {
    
    
    }
    
    
    ConnectionWeight::ConnectionWeight(int param_count,  std::vector<double>* w_array) {
    
        this->param_indices = new int[param_count];
    
        this->weight_array = w_array;
    
        if(this->param_indices){
            delete [] this->param_indices;
            this->param_indices = nullptr;
    
        }
    }
    
    void ConnectionWeight::adjust_weights(double *values) {
        for(int i = 0; i < this->n_params; ++i){
    
            this->weight_array->at(this->param_indices[i]) += values[i];
    
    David Vojtek's avatar
    David Vojtek committed
    std::vector<double> ConnectionWeight::get_weights(){
        return *this->weight_array;
    }
    
    
    void ConnectionWeight::set_weights(double *values) {
        for(int i = 0; i < this->n_params; ++i){
    
            this->weight_array->at(this->param_indices[i]) = values[i];
    
    void ConnectionWeight::SetParamIndices(int *param_indices) {
    
        for(int i = 0; i < this->n_params; ++i){
    
            this->SetParamIndex(param_indices[i], i);
    
    void ConnectionWeight::SetParamIndex(int value, int idx) {
        this->param_indices[idx] = value;
    
        double product = 1;
        for(auto e : *this->weight_array) {
            product *= e;
        }
    
        return product;