//In other words, this equilavent to cv::Mat1f mat(5,n)
//i.e. a matrix 5xn
std::vector mat(5,cv::Mat1f::zeros(1,n));
std::vector indexes(m
Types such as cv::Mat1f, that use references instead of copying, are indeed dangerous in this context. You make a clear explicit solution by splitting the parallel region and the for loop.
#pragma omp declare reduction(vec_mat1f_plus : std::vector : \
std::transform(omp_out.begin(), omp_out.end(), omp_in.begin(), omp_out.begin(), std::plus()));
// initializer not necessary if you initialize explicitly
std::vector mat;
#pragma omp parallel reduction(vec_mat1f_plus : mat)
{
mat = std::vector(5);
for (auto& elem : mat) {
elem = cv:Mat1f::zeros(1, n);
}
#pragma omp for
for(size_t i=0; i
I haven't tested whether std::plus works, but it looks good.
Your approach with vectMat will also work if you provide an operator= that deep-copies the underlying Mat with clone(), and keep the initializer.