Connection.cpp 1.11 KB
Newer Older
1 2 3 4 5 6 7 8 9
/**
 * DESCRIPTION OF THE FILE
 *
 * @author Michal Kravčenko
 * @date 13.6.18 -
 */

#include "Connection.h"

10 11 12 13 14 15
Connection* Connection::get_copy(Neuron *n_in, Neuron *n_out){
    Connection *output = new Connection(n_in, n_out, this->con, false);
    return output;
}

Connection::Connection(Neuron *n_in, Neuron *n_out, ConnectionWeight* con, bool del_weight) {
16 17
    this->neuron_in = n_in;
    this->neuron_out = n_out;
18 19

    this->con = con;
20
    this->delete_connection = del_weight;
21 22
}

23
Connection::~Connection() {
24
    if(this->con && this->delete_connection ){
25 26 27 28
        delete this->con;
        this->con = nullptr;
    }
}
29

30 31
void Connection::adjust_weights(double* values) {
    this->con->adjust_weights(values);
32 33
}

34

35 36 37 38 39 40 41 42
Neuron* Connection::get_neuron_in() {
    return this->neuron_in;
}

Neuron* Connection::get_neuron_out() {
    return this->neuron_out;
}

43 44 45
//double Connection::get_weight() {
//    return this->weight;
//}
46 47

void Connection::pass_signal() {
48
    this->neuron_out->adjust_potential(this->neuron_in->get_state() * this->con->eval());
49 50
}

51 52
void Connection::set_weights(double *values) {
    this->con->set_weights(values);
53
}