|
Ublas : |
From: Peter Melchior (pmelchior_at_[hidden])
Date: 2005-10-20 09:53:45
On Thu, 2005-10-20 at 16:44 +0200, Eddie.Vedder_at_[hidden] wrote:
> Dear list,
>
> I try to write my own class vector3d inherited from ublas::vector as
> proposed at
> http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_UBLAS.
> How can I assign an element of the vector within the constructor? I tried to
> operator () and data(), but both didn't work.
>
> Example:
> vector3d( double x, double y, double z )
> {
> operator () (0) = x;
> data () [0] = x;
> }
>
> Can anybody help?
>
> Ed
>
Hello Ed,
try something like this (which is for 2D points, inherited from vector):
typedef boost::numeric::ublas::vector
<double,boost::numeric::ublas::bounded_array<double,2> > Base_vector;
...
Point2D(double x0, double x1) : Base_vector(2) {
Base_vector::operator()(0) = x0;
Base_vector::operator()(1) = x1;
}
...
Best regards,
Peter