|
Ublas : |
Subject: Re: [ublas] fixed size vector in boost::numeric::ublas?
From: Karl Meerbergen (Karl.Meerbergen_at_[hidden])
Date: 2010-07-23 16:07:10
Jesse Perla wrote:
> Vardan Akopian <vakopian <at> gmail.com> writes:
>
>> ), defines the resize() method. Moreover it has a post condition
>> v.size () == n. So not having an implementation would break the
>> concept, having an empty implementation would break the concept's post
>> condition. A third option is to throw an exception (saying that it
>> cannot be resized). I'm not sure if throwing an exception technically
>> breaks the concept. If it does not, then we're fine. Otherwise, we
>> should either consider changing the concept, or agree that
>> fixed_vector does not implement the Vector concept (in which case
>> naming it a "..._vector" is somewhat misleading).
>>
>
> I strongly prefer having the .resize() function on any constant sized vector to
> aid in generic programming (exactly for this reason).
>
> The solution to me seems that .resize() should exist, but it should assert
> that you are trying to resize it to the exact same size as the fixed size
> (at which point it becomes a null operation), or else it throws an exception.
> This has come up in my code more than once.
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: karl.meerbergen_at_[hidden]
>
I am really surprised to see that resize() should be a member function
of a vector. Usually, in numerical codes you avoid to do resizes and
many numerical algorithms do not require resizes at all (fortunately). I
would make an additional concept for a ResizableVector.
Best,
Karl
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm