Boost logo

Ublas :

Subject: [ublas] RE : unexpected result with vector_slice
From: TENG Wenxuan (wteng_at_[hidden])
Date: 2009-06-12 09:21:12

due to the "undeliverable problem of the mail forwarding loop" I just wonder if you have received my email. I'm sorry if it is duplicated
Wenxuan Teng

-----Message d'origine-----
De : TENG Wenxuan
Envoyé : lundi 8 juin 2009 16:59
À : ublas_at_[hidden]
Objet : [ublas] unexpected result with vector_slice

Hello there,
I've observed an unexpected result when I use vector_slice with the following code:

 typedef boost::numeric::ublas::vector<double> udvector;
 typedef boost::numeric::ublas::vector<float> uvector;
 size_t block_size = 3;
 uvector v1(9);
 udvector v2(9);
 for(size_t i=0; i<9; i++) {
  v1[i] = i;
  v2[i] = i+10;
 cout << "v1="<<v1<<endl;
 cout << "v2="<<v2<<endl;
 boost::numeric::ublas::slice vs(0, 1, block_size);
 const boost::numeric::ublas::vector_slice<const udvector> blk_v1(v1, vs);
 cout << "blk_v1=" << blk_v1 << endl;
 udvector blk_v2(boost::numeric::ublas::project(v2, vs));
 cout << "blk_v1=" << blk_v1 << endl;

The ouput of the above code :


The last line of the output shows that the content of the vector_slice<const udvector> blk_v1 is wrong. I wonder if the problem is due to the fact that vector_slice has the different type (double) as the vector v1(float). However, there is not any compilation warnings or errors for this. Moreover, the problem doesn't show up if we just switch the order of the two lines such that :
udvector blk_v2(boost::numeric::ublas::project(v2, vs))
const boost::numeric::ublas::vector_slice<const udvector> blk_v1(v1, vs);
could anyone explain, thank you
Myt est environment: Linux centos, gcc3_4, boost 1_38
Wenxuan Teng


__________ Information provenant d'ESET NOD32 Antivirus, version de la base des signatures de virus 4138 (20090608) __________

Le message a été vérifié par ESET NOD32 Antivirus.