Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2007-12-10 11:47:19


Neal Becker wrote:
> Either I completely misunderstand something, or zero_vector is
> seriously broken:
>
> #include <boost/numeric/ublas/vector.hpp>
> #include <iostream>
> #include <iterator>
> #include <algorithm>
>
> using namespace std;
> namespace ublas = boost::numeric::ublas;
>
> int main() {
> ublas::zero_vector<double> zeros (10);
> copy (zeros.begin(), zeros.end(), ostream_iterator<double> (cout, "
> ")); }
>
> I expect this to print 10 '0'. Instead, it prints nothing.

This would be best posted to the uBlas mailing list, but it looks as though
zero_vector<> is a lightweight object that doesn't actually store anything:
if you ask for a value it'll return a const reference to a static data
member that stores the "zero". Even so I would have expected it's iterators
to "do the right thing" and iterate over .size() zeros.

HTH, John.


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