open source project hosted by : this is a mirror of : Introduction Screenshots Documentation Other distributed computing projects Drafts for developers Download (~1.5MB) @PU Team Contact |
A way for computing PiDescription of the plugin greekpi.dllGreekpi is a plugin which computes Pi with the Monte Carlo method. Although not very useful in real life (206 billion of digits of Pi are known), it is a good academic example. The idea is to generate two random numbers between 0 and 1, which are considered as coordinates in the plane. Let’s call these two coordinates x and y. Now the plugin checks if the point (x,y) lies within a circle of radius 1. To do this square x and y, sum them together and check if the result is less than one. If the point (x,y) lies in the circle, increment the counter Sum by one. function pi(var stk : TStack):Boolean;stdcall; var Idx : Integer; Count,Sum,i : Longint; begin Result := False; Idx := stk.StIdx; {this should speed up and also made the code more readable} {check if enough parameters first parameter is number of throws for computing Pi} if Idx < 1 then Exit; Count := Trunc(Stk.Stack[Idx]); if Count > 625000000 then Exit; {parameter is too big and we get an overflow} Sum := 0; for i:=1 to Count do begin if (Sqr(Random)+Sqr(Random)) < 1 then Inc(Sum); end; {gives result back} Stk.Stack[Idx]:=4* Sum / Count; Result := True; end;
[Introduction]
[Screenshots]
[Documentation]
[Other distributed computing projects]
[Drafts for developers]
[Download]
[Contact]
The logo was designed by Mark Grady. Graphics are by David A. Lucas.
© 2002-2003 the GPU Development team Page generated in 2.4 milliseconds by PHP 4.4.3-dev on seeschloss.free.fr. |