I have an optimisation problem and I'm wondering what the best way to approach the problem is.
At present I have a set of matrices (mats) that I need to scale by a set of values held in a vector and then summed together. I have written the following code nut it seems to be pretty painfully slow (far more so than I would have thought).
cv::Mat sum = cv::Mat::zeros( mats[0].rows, mats[0].cols, cvType );
for( int m = 0; m < mats.size(); m++ )
{
const Type val = rowVec.at< Type >( m );
sum += val * mats[m];
}
Can anyone suggest a faster way of doing the above loop?