Re: [eigen] On std::complex<> default ctor

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On Wed, Jan 19, 2011 at 2:12 PM, Gael Guennebaud
<gael.guennebaud@xxxxxxxxx> wrote:
> The easiest way would be to explicitly add
> exceptions for complex<float> and complex<double> as follow:
>
> template<> inline std::complex<float>* aligned_new(size_t size)
> { return reinterpret_cast<T*>(aligned_malloc(sizeof(std::complex<float>)*size));
> }
>
> template<> inline std::complex<double>* aligned_new(size_t size)
> { return reinterpret_cast<T*>(aligned_malloc(sizeof(std::complex<double>)*size));
> }
>
> A more general approach would be to encode this information in the
> NumTraits struct via a RequireInitialization enum which would be false
> by default and could be enabled only for scalar types for which it is
> really necessary to call their default ctor. I'm strongly in favor for
> this second solution.

Hi,

I am all for this fix since it would not only be a performance
improvement but also more consistent in regard to memory
initialization.

I prefer the first fix since it does not introduce new parameters in
NumTraits. For custom datatypes, users could still overload
"aligned_new".

- Hauke



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/