Newer
Older

Michal Kravcenko
committed
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 14.6.18 -
*/
#include "ConnectionWeight.h"
ConnectionWeight::ConnectionWeight() {
}
ConnectionWeight::ConnectionWeight(int param_count, std::function<double(double **, int)> *f) {

Michal Kravcenko
committed
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
this->param_ptrs = new double*[param_count];
this->n_params = param_count;
this->weight_function = f;
}
ConnectionWeight::~ConnectionWeight() {
if(this->param_ptrs){
delete [] this->param_ptrs;
this->param_ptrs = nullptr;
}
}
void ConnectionWeight::adjust_weights(double *values) {
for(int i = 0; i < this->n_params; ++i){
(*this->param_ptrs[i]) += values[i];
}
}
void ConnectionWeight::set_weights(double *values) {
for(int i = 0; i < this->n_params; ++i){
(*this->param_ptrs[i]) = values[i];
}
}
void ConnectionWeight::SetParamPointer(double **param_ptr) {
for(int i = 0; i < this->n_params; ++i){
this->param_ptrs[i] = param_ptr[i];
}
}
void ConnectionWeight::SetParamPointer(double *param_ptr, int idx) {
this->param_ptrs[idx] = param_ptr;
}
double ConnectionWeight::eval() {
return (*this->weight_function)(this->param_ptrs, this->n_params);