Package org.apfloat.spi

The apfloat Service Provider Interface (SPI).

See:
          Description

Interface Summary
ApfloatBuilder An ApfloatBuilder contains factory methods to create new instances of ApfloatImpl implementations.
ApfloatImpl Interface for apfloat implementations.
BuilderFactory A BuilderFactory object contains factory methods for building the various parts of an apfloat using the Builder pattern.
ConvolutionBuilder Interface of a factory for creating convolutors.
ConvolutionStrategy Generic convolution strategy.
DataStorageBuilder Interface for determining a suitable storage type for data of some expected size.
NTTBuilder Interface of a factory for creating Number Theoretic Transforms.
NTTStrategy Number Theoretic Transform (NTT) strategy.
RadixConstants Constants related to different radixes.
 

Class Summary
ArrayAccess The ArrayAccess class simulates a C language pointer.
DataStorage Generic data storage class.
DataStorage.Iterator Iterator for iterating through elements of the data storage.
FilenameGenerator Class for generating filenames for temporary files.
Util Miscellaneous utility methods.
 

Package org.apfloat.spi Description

The apfloat Service Provider Interface (SPI).

The apfloat API is a high-level API that defines algorithms on the level of e.g. the Newton iteration for the inverse of a number. Behind this high-level API there is a lot of low-level functionality that makes all the arbitrary precision arithmetic happen. The digits of a large number are stored in an array of ints, for example. In fact, an Apfloat is structurally just a pointer to an ApfloatImpl, and most of the functionality of the Apfloat class is simply delegated to the underlying ApfloatImpl.

The apfloat SPI defines the general interface for the low-level things that must happen behind the scenes of the high-level API. An actual implementation of the SPI can be optimized for different things, for example:

A Service Provider is only required to implement the BuilderFactory interface, and actually only the BuilderFactory.getApfloatBuilder() method in this interface. All apfloat implementations (ApfloatImpl) are created through the ApfloatBuilder interface's methods. The rest of the interfaces in the SPI exist only for the convenience of the default apfloat SPI implementations (org.apfloat.internal).

The apfloat SPI suggests the usage of various patterns, as encouraged by the specification of all the interfaces in the SPI. These patterns include:

Associations of the SPI classes are shown in a class diagram format below:

The class implementing BuilderFactory that is used in creating apfloat implementations is defined in the ApfloatContext. You can set the BuilderFactory instance programmatically by calling ApfloatContext.setBuilderFactory(BuilderFactory), for example:

BuilderFactory builderFactory = new MyBuilderFactory();
ApfloatContext.getContext().setBuilderFactory(builderFactory);
It's a lot easier to specify this to happen automatically whenever your program starts. To do this just specify the BuilderFactory class name in the apfloat.properties file (or the apfloat ResourceBundle if you use one). For example, the apfloat.properties file might contain the line:

builderFactory=org.mycompany.MyBuilderFactory
For more details about configuring the apfloat BuilderFactory, see the documentation for ApfloatContext.

See Also:
org.apfloat.internal