|
Boost Users : |
Subject: Re: [Boost-users] Multiplying a matrix and vector ===> vector
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2012-10-26 22:24:16
> 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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net