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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a30e9cc47b5029fe X-Google-Attributes: gid103376,public From: "Clifford J. Nelson" Subject: Re: ratioanl number type Date: 1999/12/11 Message-ID: <385252FF.BB4C7A5@gte.net>#1/1 X-Deja-AN: 559339211 Distribution: world Content-Transfer-Encoding: 7bit References: <38473D8A.9BB68676@gte.net> <3847E5B3.B96339A8@iforex.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="4D4F5353" X-Abuse-Info: Otherwise we will be unable to process your complaint properly X-Complaints-To: abuse@gte.net X-Trace: +LPib9nB5hDdFdic9ZKQxOHpSf/aYFBZXtrRE7WqUH31NnXS4y1Nh42UfQPosw8L8vWoS0M5HgCe!bLLX5sSC9uk3XVQVads7lneWpmfMC4L35Uywgw3qukpmL2urQA== MIME-Version: 1.0 NNTP-Posting-Date: Sat, 11 Dec 1999 12:50:55 GMT Reply-To: cnelson9@gte.net Newsgroups: comp.lang.ada Date: 1999-12-11T00:00:00+00:00 List-Id: Dmitriy Anisimkov wrote: > "Clifford J. Nelson" wrote: > > > Are there any Ada95 examples in books or on the web that implement the > > exact rational number data type, > > ....... > > > available > > memory should be the only limit to their size. > > Try http://www.chat.ru/~vagul/Unlimit7.zip A timing test of GNAT Ada95 CodeBuilder 1.1 exact rational numbers with unlimited size integers using http://www.chat.ru/~vagul/Unlimit7.zip compared to Mathematica 3.01. Ada95 took 4861.733319000 seconds. Mma took 15.2667 seconds. First[Timing[vtt = tt[t]-a]] 15.2667 Second 4861.733319000/15.2667 318.453 Mathematica unlimited exact rational arithmetic is 318 times faster in this test. Here is the Mathematica code. Translate it into other languages or use other packages in Ada and see how long it takes. vtt should be all zeros (97 of them). Other odd primes instead of 97 should work too. So, test it for 5 first to see if it works. See: http://forum.swarthmore.edu/epigone/geometry-research/brydilyum tt[x_] := timesbnum[x,divperm[x]] eigen[x_,n_] :=Append[x[[Mod[Range[Length[x]-1]*n, Length[x]] ]],Last[x]] conjugate[x_] := Module[{xx = eigen[x,2]}, Do[xx = timesbnum[xx,eigen[x,i]],{i,3,Length[x]-1}];xx] procal[x_,y_] :=y/((-y.Reverse[x])/Length[x]) divperm[x_] :=procal[x,conjugate[x]] timesbnum[x_, y_] := dt[-Reverse[x], y, Length[x]] dt[x_, y_, n_] := Table[RotateRight[x, i] . y, {i, 0, n - 1}]/n makezero[x_] := Join[x, {-Plus @@ x}] a = makezero[Table[1,{96}]] t = makezero[Range[96]] First[Timing[vtt = tt[t]-a]] 15.2667 Second 4861.733319000/15.2667 318.453 Cliff Nelson