From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,47fc49812a5e8e38 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: small example, using complex variables in Ada References: Date: Thu, 10 Jun 2010 03:23:57 -0400 Message-ID: <82ljannyeq.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (windows-nt) Cancel-Lock: sha1:kMf3jQqKMyiU2wuE/TvUF8eel+Y= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 9e9444c10931be197caa703907 Xref: g2news2.google.com comp.lang.ada:12528 Date: 2010-06-10T03:23:57-04:00 List-Id: "Nasser M. Abbasi" 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