Re: [eigen] On std::complex<> default ctor |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] On std::complex<> default ctor
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Thu, 20 Jan 2011 09:46:17 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=V6QaUH1AW3nvqD7eyUzMkaRrjAAvaJrlRODa530VlHY=; b=lHvBoUzdcwUL6iLm84mk6YMCbU4V99HE+vzUuWICCFF05Uu1GuvZRMRCfdRYQWihsY pg9tESbmV6yPI72tjnLDy/0MeDHF8Sm5SaOp0QWgw+3n9hehELT4GbTAN0IN68MPCIJr kqzhXbYwHiTCEVRQC/KVh4/sbZgeX4Gs/0OSg=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=eimGsm0QBr9wNd7QiUJ8t2mV4X+wgaY6o6cVWcLJWOejgCZq4zce07TJvrFwFpCWI0 dujV6Ji8yYNCcJcVKM+J3Axj35YUT77TsA1C1ar44CHx4JNwPTRd2WXAJ00rl4js9UTB fnpIKuZKAN5N+UuzPZC2bMJH7QaYasO4pELko=
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