Quick question.. I'm trying to get the mean of a matrix (vector) now before I created a function that did it but I thought that it isn't really an effective way of coding. I've been looking at the accumulate function online and wanted to ask if this would work:

double Matrix1Mean = accumulate(matrix1.begin(),matrix1.end(),init)/(size_row*size_col);

Thanks :)

Should work fine but why not just divide by matrix1.size()?

commented: Agree, infact he should generalize it into a CalculateMean function +12