|
Boost Users : |
From: e r (erwann.rogard_at_[hidden])
Date: 2007-11-09 23:46:04
hi all,
i'm trying to assign a unit vector into a vector. i get puzzling results:
v[3](0,0,0)//initial
uv1[3](1,0,0)
v[3](1,0,0)
uv2[3](0,1,0)
v[3](1,0,0)//should be (0,1,0)
uv3[3](0,1,0)
v[3](1,0,0)//should be (0,0,1)
for the code below. i must be missing something obvious...what is it?
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/io.hpp>
int main(){
using namespace boost::numeric::ublas;
unsigned int D = 3;
unit_vector<unsigned int> uv1(D,0);
unit_vector<unsigned int> uv2(D,1);
unit_vector<unsigned int> uv3(D,2);
vector<unsigned int> v(D);
std::cout << "v" << v << std::endl;
copy(uv1.begin(),uv1.end(),v.begin());
std::cout << "uv1" << uv1 << std::endl;
std::cout << "v" << v << std::endl;
copy(uv2.begin(),uv2.end(),v.begin());
std::cout << "uv2" << uv2 << std::endl;
std::cout << "v" << v << std::endl;
copy(uv3.begin(),uv3.end(),v.begin());
std::cout << "uv3" << uv2 << std::endl;
std::cout << "v" << v << std::endl;
return 0;
};
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