Boost logo

Ublas :

Subject: Re: [ublas] fixed size vector in boost::numeric::ublas?
From: Markus Grabner (grabner_at_[hidden])
Date: 2010-08-03 19:37:26


Nasos Iliopoulos wrote:

>
> Markus,
>> As I said in my previous message, fixed_vector was an easy exercise. >
>> However, a fixed_matrix is much more complicated since ublas::matrix
>> already > includes members "size1_" and "size2_" to define the matrix
>> size. I don't > know of any method to "get rid of" these members in a
>> derived class (such > that - again - a contiguous array of matrix
>> coefficients can be cast to an > array of fixed_matrix). Instead I
>> experimented with the following approac...
> I think I had some reasoning in the past against the appropriateness of
> using matrix_container to derive the fixed_matrix. As I am thinking it
> again I cannot find a reason anymore. Do you think the fixed_matrix (and
> maybe the fixed_vector) can be derived from those? Everything should be
> working, as uBlas is designed to work on expressions (containers are
> expressions) rather than matrices and vectors.
I don't see troubles with deriving the fixed_[vector|matrix] from [vector|
matrix]_container, but I didn't look too deep into the matrix case yet.

>> ... Instead I experimented with the following approach: ....
>> Your
>> suggestions will also work, but doing such a radical change looks
>> terrifying to me from backwards compatibility assurance perspective.
>> Doing that will probably require some serious dedication to make sure
>> things are working.
I agree with this. Fortunately I found a less radical approach :-) which
doesn't require an additional base class (matrix_base in my previous
proposal) in the class hierarchy. If the matrix template has a fourth
template parameter specifying a class which provided the matrix size, and
its default argument is a class which allows for dynamic resizing, the
matrix behaves exactly as before. The fixed_matrix (which is derived from
matrix) just has to override this default template argument to a class which
provides a static size.

A patch implementing this proposal is attached (also includes the
fixed_vector class discussed before). What do you think about it?

        Kind regards,
                Markus

-- 
Markus Grabner
Institute for Computer Graphics and Vision
Graz University of Technology, Inffeldgasse 16a/II, 8010 Graz, Austria
WWW: http://www.icg.tugraz.at/Members/grabner