|
Ublas : |
From: Rob McDonald (ramcdona_at_[hidden])
Date: 2008-08-20 18:19:32
Jesse Manning wrote:
> also you could do this for the 3 variable constructor:
>
> class vector3 : public ublas::vector<double,
> ublas::bounded_array<double,3> >
> {
> typedef ublas::vector<double, ublas::bounded_array<double,3> >
> Base_vector;
> public:
> // Default construction
> vector3 (double x, double y, double z) : Base_vector(3)
> { data()[0] = x; data()[1] = y; data()[2] = z; }
> // Construction and assignment from a uBLAS vector expression or
> copy assignment
> template <class R> vector3 (const ublas::vector_expression<R>& r) :
> Base_vector(r)
> {}
> template <class R> void operator=(const ublas::vector_expression<R>& r)
> {
> Base_vector::operator=(r);
> }
> template <class R> void operator=(const Base_vector& r)
> {
> Base_vector::operator=(r);
> }
> };
>
> I took this class from the effective ublas wiki and just added the
> constructor you wanted.
>
> Link to effective ublas wiki:
> http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_UBLAS
>
Jesse,
I took my initial inspiration from the same page on the wiki.
Unfortunately, when I implemented much the same thing, it didn't work.
I've tried yours and it appears to work.
Here is the error message mine gives. It appears to be because mine is
still generic code...
vect.h:89: error: there are no arguments to `data' that depend on a
template parameter, so a declaration of `data' must be available
vect.h:89: error: (if you use `-fpermissive', G++ will accept your code,
but allowing the use of an undeclared name is deprecated)
Do you have any suggestions to make data () [] generic?
Rob