|
Ublas : |
Subject: [ublas] How to iterate and print Boost Ublas' Vector
From: Gundala Viswanath (gundalav_at_[hidden])
Date: 2009-01-29 09:46:14
Hi,
I tried to print Boost Ublas vector here.
But somehow it gives error. What's the right way to do it?
// Begin
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/assign.hpp>
#include <vector>
using namespace 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;
}
}
- Gundala Viswanath
Jakarta - Indonesia