org.apfloat.samples
Class PiDistributed.DistributedChudnovskyPiCalculator

java.lang.Object
  extended by org.apfloat.samples.Pi.AbstractBinarySplittingPiCalculator
      extended by org.apfloat.samples.Pi.ChudnovskyPiCalculator
          extended by org.apfloat.samples.PiParallel.ParallelChudnovskyPiCalculator
              extended by org.apfloat.samples.PiDistributed.DistributedChudnovskyPiCalculator
All Implemented Interfaces:
Serializable, Operation<Apfloat>
Enclosing class:
PiDistributed

protected static class PiDistributed.DistributedChudnovskyPiCalculator
extends PiParallel.ParallelChudnovskyPiCalculator

Distributed version of the Chudnovskys' binary splitting algorithm. Uses multiple computers to calculate pi in parallel.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apfloat.samples.Pi.AbstractBinarySplittingPiCalculator
precision, radix
 
Constructor Summary
PiDistributed.DistributedChudnovskyPiCalculator(long precision, int radix)
          Construct a distributed pi calculator with the specified precision and radix.
 
Method Summary
protected  OperationExecutor[] getNodes()
          Get the available set of operation executor nodes.
protected  void r(long n1, long n2, ApfloatHolder T, ApfloatHolder Q, ApfloatHolder P, ApfloatHolder F, OperationExecutor[] nodes, Pi.BinarySplittingProgressIndicator progressIndicator)
          Entry point for the parallel binary splitting algorithm.
protected  OperationExecutor[] recombineNodes(OperationExecutor[] nodes, int numberNeeded)
          Attempt to combine or split nodes to form the needed number of nodes.
 
Methods inherited from class org.apfloat.samples.PiParallel.ParallelChudnovskyPiCalculator
execute
 
Methods inherited from class org.apfloat.samples.Pi.ChudnovskyPiCalculator
a, p, q
 
Methods inherited from class org.apfloat.samples.Pi.AbstractBinarySplittingPiCalculator
r
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PiDistributed.DistributedChudnovskyPiCalculator

public PiDistributed.DistributedChudnovskyPiCalculator(long precision,
                                                       int radix)
Construct a distributed pi calculator with the specified precision and radix.

Parameters:
precision - The target precision.
radix - The radix to be used.
Method Detail

r

protected void r(long n1,
                 long n2,
                 ApfloatHolder T,
                 ApfloatHolder Q,
                 ApfloatHolder P,
                 ApfloatHolder F,
                 OperationExecutor[] nodes,
                 Pi.BinarySplittingProgressIndicator progressIndicator)
          throws ApfloatRuntimeException
Description copied from class: PiParallel.ParallelChudnovskyPiCalculator
Entry point for the parallel binary splitting algorithm.

Overrides:
r in class PiParallel.ParallelChudnovskyPiCalculator
Parameters:
n1 - Start term.
n2 - End term.
T - Algorithm parameter.
Q - Algorithm parameter.
P - Algorithm parameter.
F - Pointer to inverse square root parameter.
nodes - The operation executors to be used for the calculation.
progressIndicator - Class to print out the progress of the calculation.
Throws:
ApfloatRuntimeException

getNodes

protected OperationExecutor[] getNodes()
Get the available set of operation executor nodes. This implementation returns RemoteOperationExecutors, which execute operations on the cluster's nodes.

Overrides:
getNodes in class PiParallel.ParallelChudnovskyPiCalculator
Returns:
The nodes of the cluster.

recombineNodes

protected OperationExecutor[] recombineNodes(OperationExecutor[] nodes,
                                             int numberNeeded)
Description copied from class: PiParallel.ParallelChudnovskyPiCalculator
Attempt to combine or split nodes to form the needed number of nodes. The returned number of nodes is something between the number of nodes input and the number of nodes requested. The requested number of nodes can be less than or greater than the number of input nodes.

Overrides:
recombineNodes in class PiParallel.ParallelChudnovskyPiCalculator
Parameters:
nodes - The operation executors to recombine.
numberNeeded - The requested number of operation executors.
Returns:
The set of recombined operation executors.