Boost logo

Ublas :

Subject: Re: [ublas] bounded_matrix declaration only
From: Moritz Beber (moritz.beber_at_[hidden])
Date: 2008-11-16 11:36:46


Thanks, I'm using an unbounded_matrix now. I tried using a pointer
actually but that suffers from the same problem as a pointer to a
bounded matrix requires the same template arguments to actually be of
the same type.
Unless I cast it only later on to the correct pointer... maybe.
Anyway, I'm happy with what I got :)

On Sat, 2008-11-15 at 17:17 -0500, Benson Margulies wrote:
> Declare it as a pointer, use new when you know the size.
>
> On Sat, Nov 15, 2008 at 5:11 PM, Vardan Akopian <vakopian_at_[hidden]> wrote:
> > On Sat, Nov 15, 2008 at 7:00 AM, Moritz Beber
> > <moritz.beber_at_[hidden]> wrote:
> >> Dear members,
> >> I'm trying to use the bounded_matrix as a member variable for a class
> >> I'm currently designing. The declaration of it gives me troubles though
> >> since the way I'm currently approaching it, it would require size
> >> information for the declaration already while I naturally only have that
> >> information available at the point of construction of an object of that
> >> class. A default constructor where that info is not available yet is
> >> another story also.
> >> I suppose I could use a normal matrix but since the size of the matrix
> >> will not change at all during the existence time of the class object I
> >> thought a bounded_matrix would make sense.
> >>
> >> So the code I had in mind would look somewhat like this:
> >>
> >> myclass {
> >> bounded_matrix<double, M, N, column_major> m;
> >> ...
> >> }
> >>
> >> myclass::myclass(unsigned int rows, unsigned int cols)
> >> {
> >> m = bounded_matrix<double, rows, cols, column_major>(rows, cols);
> >> ...
> >> }
> >>
> >> Is there a way to bypass the need to give specific size information at
> >> the time of declaration?
> >>
> >> Thank you for your insights,
> >> Moritz
> >>
> >> _______________________________________________
> >> ublas mailing list
> >> ublas_at_[hidden]
> >> http://lists.boost.org/mailman/listinfo.cgi/ublas
> >>
> >
> > Moritz,
> >
> > Template parameters have to be known at compile time.
> > Just because the matrix size does not change during its existence,
> > does not mean that it is known at compile time. So your code above
> > cannot work with bounded_matrix. You either need to use
> > unbounded_matrix, or you'd need to make your class a template class as
> > well. The latter only moves the issue to another place (where you'd
> > need to instantiate myclass), so if in principle the dimensions are
> > not known at compile time, this solution will not work and you'd still
> > have to go with unbounded_matrix.
> >
> > Hope it helps
> > -Vardan
> > _______________________________________________
> > 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