Let's say that i am trying to fill a MatrixXf with the rolling mean of another MatrixXf like this
MatrixXf ComputeRollingMean(const MatrixXf& features) {
MatrixXf df(features.rows() - 30, features.cols());
for (size_t i = 30; i < features.rows(); ++i) {
MatrixXf mat = features.block(i-30, 0, 30, 3);
RowVectorXf mean_vector = mat.colwise().mean();
RowVectorXf stdev_vector = ((mat.rowwise() - mean_vector).colwise().squaredNorm() / (mat.rows()-1)).cwiseSqrt();
MatrixXf zscores = (mat.rowwise() - mean_vector).array().rowwise() / stdev_vector.array();
RowVectorXf zscore = zscores(last, all);
df.block(index, 0, 1, 3) = zscore;
}
return df;
}
It seems that Eigen has some sort of parallelism process
#include <Eigen/Core>
and then
int main() {
Eigen::initParallel();
...}
But I am not sure how this can parallelize the for loop in my ComputeRollingMean function. Anyone knows how I could parallelize, and maybe choose the number of process i want to start please?