Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
27
Task/Pi/Standard-ML/pi.ml
Normal file
27
Task/Pi/Standard-ML/pi.ml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
(* https://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/spigot.pdf *)
|
||||
|
||||
fun gibbons _ _ _ _ _ _ 0 = ()
|
||||
| gibbons q r t k n l count =
|
||||
let
|
||||
val (q',r',t',k',n',l',count') =
|
||||
if 4*q+r-t < n*t
|
||||
then (10*q,10*(r-n*t),t,k,(10*(3*q+r)) div t-10*n,l,count-1) before print (IntInf.toString n)
|
||||
else (q*k,(2*q+r)*l,t*l,k+1,(q*(7*k+2)+r*l) div (t*l),l+2,count)
|
||||
in
|
||||
gibbons q' r' t' k' n' l' count'
|
||||
end
|
||||
|
||||
fun doGibbons n = gibbons 1 0 1 1 3 3 n
|
||||
|
||||
fun timeGibbons n =
|
||||
let
|
||||
val timer1 = Timer.startCPUTimer ()
|
||||
val () = doGibbons n
|
||||
val {usr=usr, sys=sys} = Timer.checkCPUTimer timer1
|
||||
in
|
||||
print "\n----------------------\n";
|
||||
print ("usr: " ^ Time.toString usr ^ "\n");
|
||||
print ("sys: " ^ Time.toString sys ^ "\n")
|
||||
end
|
||||
|
||||
fun main () = timeGibbons 5000
|
||||
Loading…
Add table
Add a link
Reference in a new issue