This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: a note on std::complex performance



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 ;

}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]