Boost logo

Ublas :

From: Neal Becker (ndbecker2_at_[hidden])
Date: 2005-08-16 08:12:33


Michael Stevens wrote:

> Hi Neal,
>
> On Tuesday 16 August 2005 13:02, Neal Becker wrote:
>> I need a way to construct large vectors of complex numbers. I want to
>> bypass the wasteful default construction of the complex elements. What
>> would be the preferred way to do this using ublas? Has anyone already
>> done this?
>
> I have thought about this before. My feeling is that this is another issue
> with the "over encapsulation" of 'std::complex.' There is no reason why
> 'std::complex' should initialise to zero in it's default constructor. The
> class has no invariants to maintain, so it can have an uninitialised
> default constructor just as the C++ builtin types do.
>
> My "preferred" way would therefore be to use a 'complex' class which has
> an initialised default constructor. Sadly there is way such a class can be
> derived from 'std::complex', and no one want to rewrite all of complex. So
> it would be nice to force uBLAS to avoid any kind of construction.
>
> Sadly not even the STL allocator interface of the storage types allows
> this. The only way to do this would be to write a special version of
> 'unbounded_array' which avoids the standard conforming default
> construction of elements.
>
> Michael

I'm thinking maybe the array_adaptor would be the least work. I could
create my own array without default construction, then adapt it.