Boost logo

Ublas :

Subject: Re: [ublas] newbie
From: Gunter Winkler (guwi17_at_[hidden])
Date: 2008-12-16 17:19:24


Robinson, John MD PhD schrieb:
> Can anyone recommend a simple "examples program" that illustrates
> uBLAS usage. I am particularly perplexed about defining values for
> vectors and matrixs such as:
>
> ublas::vector<int> ia (6);
> ia = [ 1, 2, 3, 4, 5, 6 ] ; // <--error!
this is not supported by ublas. You have to use a for loop to define
values (or use the >> operator to read a v ector from a string). You can
also copy values from a c-array to a ublas vector:

// untested
double a[] = {1.0, 2.0, 3.0};
ublas::vector<double> x(3);
std::copy(&(a[0]),&(a[3]),x.begin()); // &(a[3]) points to the element
after the last and is never accessed

AFAIK boost::array supports a syntax like
a = 1,2,3,4,5;

please have a look at my examples:

http://www.guwi17.de/ublas

mfg
Gunter