comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: Re: small example, using complex variables in Ada
Date: Thu, 10 Jun 2010 03:23:57 -0400
Date: 2010-06-10T03:23:57-04:00	[thread overview]
Message-ID: <82ljannyeq.fsf@stephe-leake.org> (raw)
In-Reply-To: hunrki$ph7$1@speranza.aioe.org

"Nasser M. Abbasi" <nma@12000.org> writes:

> I also wrote a FORTRAN equivalent of the small Ada function.  Here is
> below the Ada code, and the FORTRAN code.  Again, do not scream too
> much if it is not good code, I just learned this now, I am sure this
> can be improved a lot.

This is an interesting comparison. Perhaps, after people finish
polishing your code, you could publish it on
http://en.wikibooks.org/wiki/Ada_Programming 

> -- gnatmake dft.adb
> --
> -- ./dft.exe
> -- ( 6.00000E+00, 0.00000E+00)
> -- (-1.50000E+00, 8.66026E-01)
> -- (-1.50000E+00,-8.66025E-01)
> -- $
>
> ======= FORTRAN code ===========
> ! dtf.f90, compiled with GCC 4.3.4
> ! under CYGWIN 1.7.5
> ! gfortran -Wall dft.f90
> ! ./a.exe
> ! (  6.0000000    ,  0.0000000    )
> ! ( -1.4999999    , 0.86602557    )
> ! ( -1.5000005    ,-0.86602497    )
> !

It would be good to explain the small differences here; something about
how the floating point options are set, I suspect.

It would be good to state the theoretically correct answer; I hope it's
1.5, not 1.499... :).

> Conclusion:
> I actually liked the Ada implementation more than FORTRAN because:
>
> 1. In Ada, I did not have to change the index of m and k in the
> summation to reflect the 1-off per the definition of DFT.
> DFT starts from 0 to N-1. In Ada, using 'Range and defining the arrays
> to go from 0 .. N-1 solved the problem.
>
> 2. In Ada, the compiler complained more times more about types being
> mixed up. I placed float() around the places it complained about.

It's interesting that you list this as a bonus; some people would list
it is a negative feature ("_obviously_ the compiler should do that
conversion for you!").

> 3. It actually took me less time to do the Ada function than the
> FORTRAN one, even though I am equally not familiar with both at this
> time :)

That is my general experience with Ada; it takes less time to get the
result I want.

-- 
-- Stephe



  parent reply	other threads:[~2010-06-10  7:23 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-09 10:49 small example, using complex variables in Ada Nasser M. Abbasi
2010-06-09 11:26 ` Ludovic Brenta
2010-06-09 23:50   ` Jerry
2010-06-10  1:03     ` Jeffrey R. Carter
2010-06-10 15:48   ` Colin Paul Gloster
2010-06-10 14:54     ` Ludovic Brenta
2010-06-10 16:21       ` Colin Paul Gloster
2010-06-10 17:37         ` Adam Beneschan
2010-06-10 17:57         ` Jeffrey R. Carter
2010-06-10 22:32           ` Randy Brukardt
2010-06-11 12:42             ` Colin Paul Gloster
2010-06-11 18:59               ` Randy Brukardt
2010-06-14 19:19                 ` Colin Paul Gloster
2010-06-14 19:48                   ` Nasser M. Abbasi
2010-06-17  7:44     ` Gautier write-only
2010-06-17 10:33       ` Colin Paul Gloster
2010-06-17 14:39       ` Yannick Duchêne (Hibou57)
2010-06-17 16:36         ` Colin Paul Gloster
2010-06-09 12:43 ` Niklas Holsti
2010-06-10  7:23 ` Stephen Leake [this message]
2010-06-10  9:12   ` J-P. Rosen
2010-06-10 11:03     ` Yannick Duchêne (Hibou57)
2010-06-10 13:27       ` J-P. Rosen
2010-06-10 21:15         ` Yannick Duchêne (Hibou57)
2010-06-11  7:22           ` Dmitry A. Kazakov
2010-06-11  8:48           ` J-P. Rosen
2010-06-11 12:00             ` Brian Drummond
2010-06-10  9:34   ` Nasser M. Abbasi
2010-06-10 20:12     ` Simon Wright
2010-06-14  9:33 ` Vincent LAFAGE
2010-06-14 12:29   ` Nasser M. Abbasi
2010-06-14 13:00     ` Vincent LAFAGE
replies disabled

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