The maths package contains the following sub-packages:
JSci implements a wide range of numeric types as classes. The behaviour of these classes are defined in terms of algebra, field and group member interfaces (the Mathematical Structures Framework). These interfaces provide a high level of abstraction.
Most complex functions are implemented as static methods. This was done to improve code readability, e.g. Complex.sin(z)
rather than z.sin()
. The "power" methods such as sqrt
and sqr
are implemented as instance methods. This is so z.sqrt()
resembles z½. (It is also a bit faster than using a static method.)
Tip: where possible use the constants defined in the Complex class or the JSci.maths.fields.ComplexField class. These numbers are already instantiated and will reduce memory usage.
Quaternions are a generalisation of complex numbers, they have three imaginary parts rather than one. The imaginary parts are encapsulated in a 3-vector.
Supernumber objects encapsulate elements of the Grassmann algebra Lambda4. This is the same as the exterior algebra of differential forms in 4 dimensions.
The matrix and vector classes support three different numeric types. These are integer (for speed), double (for accuracy) and complex.
The square matrix classes introduce the following methods:
luDecompose
)
Decomposes a matrix M into a lower triangular matrix L and an upper triangular matrix U, such that M=LU.
choleskyDecompose
)
Similar to LU decomposition but with the addition property that U=LT. The matrix must be symmetric and positive definite for this to work correctly.
singularValueDecompose
)
Decomposes a matrix M into an orthogonal matrix U, a diagonal matrix S and an orthogonal matrix V, such that M=USVT.
inverse
)
Computes the inverse of a matrix using LU decomposition (M-1=U-1L-1).
Where ever possible, the abstract matrix/vector API should be used in preference to a particular matrix/vector implementation API.
That is, use code like AbstractDoubleVector vec = new DoubleVector(dim);
.
This philosophy is similar to that of the Java Collections Framework.
MathVector | Abstract...Vector Abstract API | --------------------------- | | | ...Vector ...3Vector ...SparseVector Implementations
Matrix | Abstract...Matrix | ----------------------------------- | | | ...Matrix ...SparseMatrix Abstract...SquareMatrix | ----------------------------------------------------------- | | | | ..SquareMatrix ...SparseSquareMatrix ...TridiagonalMatrix ...DiagonalMatrix
This consists of the interfaces in the algebras, fields and groups packages. It is the maths equivalent of the Java Collections Framework. Each interface describes a structured set, and has a nested interface which describes a member of that set.
This interface defines some commonly used numbers. It is desirable to use these where possible as it removes the need to compute them, reducing numerical errors and processor time.
The ExtraMath class contains methods that are not available in java.lang.Math. It includes the hyperbolic trigonometric functions.
This class contains methods for solving common linear algebra problems.
leastSquaresFit
)
The method of least squares is used to fit an nth degree polynomial to some given data.
solve
)
Solves a specified linear system for the unknown vector x.
eigen
[value
]SolveSymmetric
)
Returns the eigenvalues and eigenvectors of a specified matrix.
The FourierMath class contains methods for performing the FFT and the inverse FFT of an array of data. Most uses will need to wrap the sort method around the FFT method to return the output in the correct ascending order.
This package contains the interfaces for modules, vector spaces, and algebras. There are also classes that encapsulate some common Lie algebras.
This package contains the interfaces for rings and fields. There are aslo classes that encapsulate some common fields.
This package contains the interfaces for semigroups, monoids, and groups. The discrete group classes represent elements using a, b, c, e notation (e = identity). The Lie group parent class uses complex square matrices to represent its elements. All Lie group sub-classes override the LieGroup class methods in such a way as to maintain the matrix representation, even though they themselves may use a different representation.
This package contains classes that model several statistical distributions.
The ChiSqrDistribution methods are related to the Microsoft Excel CHIDIST and CHIINV functions as follows:
CHIDIST(x) = 1 - ChiSqrDistribution.cumulative(x)
CHIINV(x) = ChiSqrDistribution.inverse(1-x)
Contains some chaotic maps.
Return to the Developer's Guide contents.