From: Damien Fisher (damien_at_[hidden])
Date: 2002-02-27 23:26:36
On Wed, 27 Feb 2002, Joe Gottman wrote:
> ----- Original Message -----
> From: <nbecker_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Wednesday, February 27, 2002 2:30 PM
> Subject: Re: [boost] Re: std::complex design (Was: N-Dimensional array
> library submission...)
> > Another problem with std::complex is that is has a default
> > initializer. Constructing a vector<complex> will cause the default
> > initializer to be called potentially a large number of times. This
> > can be very wasteful. I believe a complex type for serious numerical
> > processing should not have a default constructor.
> Why not? If you write vector<complex<double> > vec(10); you have made
> a conscious decision to create a vector that started with 10 complex
> numbers. Its not unreasonable for a user to use one of those complex
> numbers. If you just wanted to reserve space for 10 complex numbers you
> could have just used the default constructor then called reserve().
> Besides, the default constructor is inline, so how slow could it be?
> Joe Gottman
100 x 100 matrix of complex numbers => 100 * 100 * 2 unnecessary
initializations. and that's not even a particularly large example.