org.apfloat.samples
Class Pi.ChudnovskyPiCalculator

java.lang.Object
  extended byorg.apfloat.samples.Pi.ChudnovskyPiCalculator
All Implemented Interfaces:
Operation, java.io.Serializable
Direct Known Subclasses:
PiParallel.ParallelPiCalculator
Enclosing class:
Pi

public static class Pi.ChudnovskyPiCalculator
extends java.lang.Object
implements java.io.Serializable, Operation

Basic class for calculating pi using the Chudnovskys' binary splitting algorithm.

See Also:
Serialized Form

Field Summary
protected  long precision
          Target precision.
protected  int radix
          Radix to be used.
 
Constructor Summary
Pi.ChudnovskyPiCalculator(long precision, int radix)
          Construct a pi calculator with the specified precision and radix.
 
Method Summary
 java.lang.Object execute()
          Calculate pi using the Chudnovskys' binary splitting algorithm.
protected  void r(long n1, long n2, ApfloatHolder T, ApfloatHolder Q, ApfloatHolder P, Pi.ChudnovskyProgressIndicator progressIndicator)
          Entry point for the binary splitting algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

precision

protected long precision
Target precision.


radix

protected int radix
Radix to be used.

Constructor Detail

Pi.ChudnovskyPiCalculator

public Pi.ChudnovskyPiCalculator(long precision,
                                 int radix)
Construct a 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,
                 Pi.ChudnovskyProgressIndicator progressIndicator)
          throws ApfloatRuntimeException
Entry point for the binary splitting algorithm.

Parameters:
n1 - Start term.
n2 - End term.
T - Algorithm parameter.
Q - Algorithm parameter.
P - Algorithm parameter.
progressIndicator - Class to print out the progress of the calculation.
Throws:
ApfloatRuntimeException

execute

public java.lang.Object execute()
Calculate pi using the Chudnovskys' binary splitting algorithm.

Specified by:
execute in interface Operation
Returns:
Return value of the operation.