This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: a note on std::complex performance
- To: libstdc++ at gcc dot gnu dot org
- Subject: Re: a note on std::complex performance
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Wed, 26 Sep 2001 11:10:23 -0700 (PDT)
Posted by request.
It would be nice if this could be examined, to figure out what's up. Any
takers?
-benjamin
---------- Forwarded message ----------
Date: Wed, 26 Sep 2001 12:25:12 +0200
From: Gerhard Wesp <gwesp@cosy.sbg.ac.at>
To: Benjamin Kosnik <bkoz@redhat.com>
Subject: Re: a note on std::complex performance
hi benj,
sorry, after an involuntary compiler upgrade (accidentally deleted the
binaries), i'm currently unable to reproduce the discrepancy. i'll get
back should it reappear sometimes.
anyway, a short benchmark program with my inner loop is included.
greetings
-gerhard
#include <complex>
typedef std::complex< double > complex ;
template< typename T > inline T sqr( T const& t ) { return t * t ; }
inline double abs_squared( complex const& z ) {
return sqr( z.real() ) + sqr( z.imag() ) ;
}
int main() {
complex c( -.1 , -.1 ) ;
complex z = c ;
long iter = 0 ;
while( ++iter < 100000000 && abs_squared( z ) < 4 ) z = z * z + c ;
}