The loop is simple enough, but I just can't seem to wrap my head around using the STL algorithms to give the same nested loop below.
const int a_size = 5; // input
const int c_size = 2; // output
const int b_size = a_size * c_size; // multipliers
std::vector<float> a(a_size);
std::vector<float> b(b_size);
std::vector<float> c(c_size);
// fill a and b with data
// this nested loop
for(int i = 0; i<c_size; i++) {
c[i] = 0.0;
for(int k = 0; k<a_size; k++) {
c[i] += (a[k] * b[i*a_size+k]);
}
c[i] = sigmoid(c[i]);
}
The reason why I would like to do this, is for the Boost.Compute library, which would do the calculations on the GPU using STL-like algorithms (std::transform, std::for_each, etc.).
Boost.Compute- it will be much more useful. For instance viaTaskGraphmethod which I described here.