Beispiel #1
0
values_t operator+(const values_t& a, const values_t& b)
{
#ifndef OPTIMIZED
    if(a.size() != b.size())
        throw "Vector addition error: wrong sizes!";
#endif
    values_t result(a.size());
    for(unsigned int i=0; i<a.size(); i++){
        result[i] = a[i]+b[i];
    }
    return result;
}
Beispiel #2
0
void Neuron::feed(const values_t& input)
{
#ifndef OPTIMIZED
    if(input.size() != connections.size()){
        throw "Invalid fire sizes!";
    }
#endif

    value = bias;

    for(int i=0; i<input.size(); i++){
        value += input[i] * connections[i];
    }
}
Beispiel #3
0
TYPE sum(const values_t& a)
{
    TYPE sum = 0.0;
    for(unsigned int i=0; i<a.size(); i++){
        sum += a[i];
    }
    return sum;
}
Beispiel #4
0
TYPE abs(const values_t& a)
{
    TYPE sum = 0.0;
    for(unsigned int i=0; i<a.size(); i++){
        sum += a[i]*a[i];
    }
    return sqrt(sum);
}
Beispiel #5
0
 void on_bars(const datetime_t& datetime, const values_t& bars)
 {
     log_trace("StrategyTest::{}", __func__);
     
     try
     {
         const value_t& bar = bars.at(symbol);
         log_debug("StrategyTest::{} {}", __func__, bar);
     }
     catch (std::exception& e)
     {
         log_error("StrategyTest::{} {}", __func__, e.what());
     }
 } 
Beispiel #6
0
void print(values_t& v)
{
    for(unsigned int i=0; i<v.size(); i++)
        printf("%.5f ", v[i]);
    printf("\n");
}
Beispiel #7
0
template <typename T> Value const& operator[](T&& key) const 
    { return values.at(std::forward<T>(key)); }