comp.lang.ada
 help / color / mirror / Atom feed
From: David Smith <david.smith@gmail.com>
Subject: Re: GNAT Optimization of Constant Expressions
Date: 18 May 2007 08:39:46 -0700
Date: 2007-05-18T08:39:46-07:00	[thread overview]
Message-ID: <1179502786.146161.217520@o5g2000hsb.googlegroups.com> (raw)
In-Reply-To: <mailman.149.1179482247.18371.comp.lang.ada@ada-france.org>

Thanks for the interesting discussion.  I always learn so much on this
group.

> Can you please post your C equivalent.

Of course:

#include <stdio.h>
#include <math.h>

int
main()
{
   const int N = 10000;
   int i, j;
   double x[N], y[N], z[N];
   //const double sinx = sin(0.5);
   //const double siny = sin(2.0*0.5);
   //const double sinz = sin(3.0*0.5);
   //const double logx = log(0.5);
   //const double logy = log(2.0*0.5);
   //const double logz = log(3.0*0.5);
   //const double sqrtx = sqrt(0.5);
   //const double sqrty = sqrt(2.0*0.5);
   //const double sqrtz = sqrt(3.0*0.5);

   for (j=1; j<=10000; ++j)
      for (i=0; i<N; ++i)
      {
         x[i] += j + sin(0.5)/1.5 + log(0.5)/2.5 +
                 sqrt(0.5)/3.3 ;
         y[i] += j + log(2.0*0.5)/1.5 + sqrt(2.0*0.5)/2.5 +
                 sin(2.0*0.5)/3.3 ;
         z[i] += j + sqrt(3.0*0.5)/1.5 + sin(3.0*0.5)/2.5 +
                 log(3.0*0.5)/3.3 ;
      }

   printf("%g %g %g\n", x[N-1], y[N-1], z[N-1]);

   return 0;
}




  reply	other threads:[~2007-05-18 15:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-16 22:37 GNAT Optimization of Constant Expressions David Smith
2007-05-17  4:50 ` Randy Brukardt
2007-05-17 20:03   ` Gautier
2007-05-17 20:46     ` Randy Brukardt
2007-05-17 22:49       ` David Smith
2007-05-17 23:38         ` Randy Brukardt
2007-05-18  7:58           ` Dmitry A. Kazakov
2007-05-18 11:27           ` Georg Bauhaus
2007-05-18 17:28             ` Randy Brukardt
2007-05-18 16:25       ` Ray Blaak
2007-05-18 17:40         ` Randy Brukardt
2007-05-18 22:51           ` Adam Beneschan
2007-05-19  2:44             ` Randy Brukardt
2007-05-18  9:05   ` Markus E Leypold
2007-05-18  9:47   ` Florian Weimer
2007-05-18 11:32     ` Duncan Sands
2007-05-18 17:20     ` Randy Brukardt
2007-05-18 17:35       ` Duncan Sands
     [not found]       ` <200705181935.23877.baldrick@free.fr>
2007-05-18 17:49         ` Duncan Sands
2007-05-17  5:30 ` Martin Krischik
2007-05-18  9:56 ` Duncan Sands
2007-05-18 15:39   ` David Smith [this message]
2007-05-18 17:08     ` Duncan Sands
     [not found]     ` <200705181908.54920.baldrick@free.fr>
2007-05-18 17:32       ` Duncan Sands
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox