27 Oct
2012
27 Oct
'12
2:24 a.m.
Alternatively, I can avoid the tmp variable altogether and get a working program to copy the result of matrix-vector multiplication onto a new vector y but then I would need two multiplications. E.g. <CODE> std::copy(prod(m,x).begin(), prod(m,x).end(), y.begin()); <CODE>
This doesn't answer your question, but I just wanted to point out that the above line is undefined behaviour, since the begin and end iterators refer to two different ranges (two different temporary variables). This problem can be avoided by using boost::copy (from Boost.Range) instead, which allows you to mention the range just once: boost::copy(prod(m, x), y.begin()); Regards, Nate