|
|||||||
| General Programming Forum devoted to general, non-Qt programming issues. |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello,
I have a matrix of int (vector of vector); the problem is that I need to compute the mean of each column (the matrix can be 500 x200); so to do this I did: Qt Code:
Qt Code:
__________________
Regards |
|
#2
|
|||
|
|||
|
It won't be faster, because std::accumulate will iterate the vector as well... What you can do is to calculate all columns at once and store results in a temporary vector. It won't be much faster though - you have to iterate all columns in all rows ending up with a complexity of O(n x m) anyway. The only benefit you might have is proper use of cpu cache. You could try making things faster by calculating more than one cell at once (by reading/summing all columns in one machine instruction), but you can have overflows then.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|