The following code is a bare-bones simplification of a much larger project.It calculates the mean value of a large vector expression.
When the mean_calculator class contains the vector-expression itself (instead of a ref to it), which is morre expensive because of the copy-c/tor,
the first time it is ran the result is pretty random, while the subsequent calls give the same number (as far as I can tell).
When, though it contains a (const) ref to the vector-expression, anything goes as far a result is concerned.
The mean_calculator only operates on a part of the vector and, more importantly, only reads info.
Any idea for why this behavior ?
Thank you very much in advance,
PS: I know, that MKL has Summary Statistics, but this is not what I am after. This is only an example
that I need to understand.