|
Ublas : |
From: Langeland, Stian (GE Healthcare) (Stian.Langeland_at_[hidden])
Date: 2007-05-29 05:03:12
I think I need to clarify what I need to do :-) It is a bit difficult to
explain so I will try to to use some pseudo code:
typedef c_vector<float, 3> point;
double *pp;
point p1(0.0f, 0.1f, 0.2f);
point p2(1.0f, 1.1f, 1.2f);
std::vector<point> points;
points.push_back(p1);
points.push_back(p2);
pp = &(points[0])(0); //pp should point to p1(0)
pp++;//pp point to p1(1)
pp++;//pp point to p1(2)
pp++;//pp point to p2(0)
pp++;//pp point to p2(1)
...
however as the
size_type size_;
is a member of c_vector this will not work.
Stian
> -----Original Message-----
> From: ublas-bounces_at_[hidden]
> [mailto:ublas-bounces_at_[hidden]] On Behalf Of Nico Galoppo
> Sent: 29. mai 2007 10:39
> To: ublas mailing list
> Subject: Re: [ublas] Vector of size 3 without the size element
>
> Can't you just subclass c_vector and provide an accessor to
> data_ ? Some pseudo
> code:
>
> template <typename T>
> class vector3 : public ublas::c_vector<real_type, 3> {
> ..
> public:
> array_type::value_type* data() { return data_; }
> ..
> }
>
> Then you can do
>
> typedef vector3<float> vector3f;
> vector3f p(0.0f, 1.0f, 1.0f);
> glVector3fv(p.data());
>
> or, I think you should be able to do the following with a
> regular c_vector
>
> c_vector<float, 3> p(0.0f, 1.0f, 1.0f);
> glVector3fv(&p(0));
>
> HTH,
>
> --nico
>
> Langeland, Stian (GE Healthcare) wrote:
> > Thanks for such a quick reply. I have considered the
> c_vector but when I
> > looked in vector.hpp I see that it has a member size_
> > ....
> > private:
> > size_type size_;
> > array_type data_;
> > ....
> > I guess this will still come in-between the floats?
> >
> > Stian
> >
> >> -----Original Message-----
> >> From: ublas-bounces_at_[hidden]
> >> [mailto:ublas-bounces_at_[hidden]] On Behalf Of Dima Sorkin
> >> Sent: 29. mai 2007 10:11
> >> To: ublas mailing list
> >> Subject: Re: [ublas] Vector of size 3 without the size element
> >>
> >> Hi.
> >> It can be c_vector, from
> >> http://www.boost.org/libs/numeric/ublas/doc/types_overview.htm
> >>
> >> I don't sure that if you put an array of c_vector, then all
> >> floating numbers will sit continuously in memory (compiler
> >> can add some
> >> spaces).
> >>
> >> May be a 3xN matrix fits your needs ?
> >>
> >> Regards,
> >> Dima.
> >>
> >> Quoting "Langeland, Stian (GE Healthcare)"
> <Stian.Langeland_at_[hidden]>:
> >>
> >>> Hi,
> >>>
> >>> I have been trying to create a vector of 3 elements (a
> >> point) without
> >>> the size element stored in the object. The reason for
> this is that I
> >>> need to be able to have all the elements consecutive in
> memory when
> >>> gathering several points in a std::vector. In this way all
> >> points in the
> >>> std::vector can be uploaded to a graphics card using a
> >> single memcopy.
> >>> Can this be acheived using ublas? I have not been able to
> >> find a way.
> >>> Thanks,
> >>> Stian
> >>> _______________________________________________
> >>> ublas mailing list
> >>> ublas_at_[hidden]
> >>> http://lists.boost.org/mailman/listinfo.cgi/ublas
> >>>
> >> _______________________________________________
> >> ublas mailing list
> >> ublas_at_[hidden]
> >> http://lists.boost.org/mailman/listinfo.cgi/ublas
> >>
> > _______________________________________________
> > ublas mailing list
> > ublas_at_[hidden]
> > http://lists.boost.org/mailman/listinfo.cgi/ublas
>
> --
> Nico Galoppo UNC-CH PhD. student http://www.ngaloppo.org
> +1-919-942-4388
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
>