// Begin
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/assign.hpp>
#include <vector>
usingnamespace std;
namespace ublas = boost::numeric::ublas;
int main () {
ublas::vector<double> v1 (10);
for (unsigned i = 0; i < v1.size (); ++ i){
v1 (i) = i;
}
// This is not I want
//cout << v1 << endl;
// I want to print this way instead
// but give error, how to do it correctly?
for (int i = 0; v1.size(); i++) {
cout << v1(i) << endl;
}
}
The error message I got is this:
1 2 3 4
check failed in file /opt/local/include/boost/numeric/ublas/storage.hpp at line 195:
i < size_
terminate called after throwing an instance of 'boost::numeric::ublas::bad_index'
what(): bad index