Class Pi

java.lang.Object
  |
  +--Task
        |
        +--Pi
All Implemented Interfaces:
net.jini.core.entry.Entry, java.io.Serializable

public final class Pi
extends Task

Compute PI by evaluating the integral(4/(1+x*x)dx) from 0 to 1, which can be approximated by the discrete sum(4 / ((1+(k-1/2)**2))(1/N)) from k=1 to N. Not terribly fast, but didactically useful and easily coded for distribution to multiple machines.

Author:
Copyright (c) 2000,2003 mnoble@space.mit.edu
This code may only be used under the terms of GNU General Public License.
See Also:
Serialized Form

Field Summary
 java.lang.Long N
           
 java.lang.Long stepsize
           
 
Fields inherited from class Task
data, done, id, result
 
Constructor Summary
Pi()
           
Pi(long workerID, long nsubIntervals, long nworkers)
           
 
Method Summary
protected  java.lang.Object compute()
           
 java.lang.Object mergeResult(java.lang.Object r)
           
 java.lang.String name()
           
 void reportResult(java.lang.Object r)
           
 
Methods inherited from class Task
execute, finalize, keepData
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

N

public java.lang.Long N

stepsize

public java.lang.Long stepsize
Constructor Detail

Pi

public Pi()

Pi

public Pi(long workerID,
          long nsubIntervals,
          long nworkers)
Method Detail

compute

protected java.lang.Object compute()
Overrides:
compute in class Task

mergeResult

public java.lang.Object mergeResult(java.lang.Object r)
Overrides:
mergeResult in class Task

reportResult

public void reportResult(java.lang.Object r)
Overrides:
reportResult in class Task

name

public java.lang.String name()
Overrides:
name in class Task