Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/tests/nofib/imaginary/x2n1/Main.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


{-
Date: Tue, 15 Dec 92 14:39:56 +0100
From: Lennart Augustsson <[email protected]>
Message-Id: <[email protected]>
To: [email protected]
Subject: Re: ghc 0.10 in animal:pub/incoming

...

I'd also like to contribute a small benchmark to your nofib suite, but it is
of the nfib kind:

<below>

It compute a root to the equation x^n = 1 (i.e. mkPolar 1 (2*pi/fromInt n)),
and raises it to the n:th power to get 1, sums a few of these and prints the
result.  The result of this program should be 10000.  It a reasonable test
of how well complex numbers are handled by the compiler.
My ulteriour motive for suggesting this benchmark is that the next version
of hbc will do pretty well on this example.  Since you have had the choice
of all the other programs I thought I'd contribute at least one :-)

...
-}

module Main ( main ) where
import Complex

main = print (round (realPart (sum [f n | n <- [1..10000]])))

f :: Int -> Complex Double
f n = mkPolar 1 ((2*pi)/fromIntegral n) ^ n

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].