# Maths Package

The maths package contains the following sub-packages:

- Statistics
- Chaos
- Groups
- Algebras
- Wavelet

### Interface descriptions

#### NumericalConstants

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.

### Class descriptions

#### Complex

Complex functions are implemented as static methods. This was done to improve code readability, e.g. `Complex.sin(z)` rather than `z.sin()`.

Tip: where possible use the constants defined in the Complex class. These numbers are already instantiated and will reduce memory usage.

#### Matrix and Vector classes

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:

- LU decomposition (`luDecompose`)

  Decomposes a matrix (M) into lower (L) and upper (U) triangular matrices, such that LU=M.

- Cholesky decomposition (`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.

- Inverse (`inverse`)

  Computes the inverse of a matrix using LU decomposition (M-1=U-1L-1).

#### ExtraMath

The ExtraMath class contains methods that are not and should be available in java.lang.Math. These consist of the hyperbolic trigonometric functions.

#### LinearMath

This class contains methods for solving common linear algebra problems.

- Curve fitting - method of least squares (`leastSquaresFit`)

  The method of least squares is used to fit an nth degree polynomial to some specified data. A vector is returned containing the polynomial's coefficients. These are in ascending degree order, i.e. c0 + c1 x + c2 x2 + ...

- Solving linear systems - Mx=b (`solve`)

  Solves a specified linear system for the unknown vector x. Requires the matrix to have first been decomposed into lower and upper triangular matrices. Either LU decomposition or Cholesky decomposition may be used.

- Eigenvalue/Eigenvector problems - Mx=kx (`eigen`[`value`]`SolveSymmetric`)

  Returns the eigenvalues and eigenvectors of a specified matrix.

#### FourierMath

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.

### Class hierarchy

#### Vector tree

     MathVector
         |
    ...Vector
         |
         ------------------
         |                |
    ...3Vector     ...SparseVector

#### Matrix tree

         Matrix
           |
      ...Matrix
           |
           ------------------------
           |                      |
    ...SquareMatrix      ...SparseMatrix
           |
    ...TridiagonalMatrix
           |
    ...DiagonalMatrix

### Statistics

This package contains classes that model several statistical distributions.

### Chaos

Contains some chaotic maps.

### 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.

### Algebras

This package contains classes that encapsulate some common Lie algebras.

Return to the Developer's Guide contents.