finMath lib documentation

net.finmath.functions
Class LinearAlgebra

java.lang.Object
  extended by net.finmath.functions.LinearAlgebra

public class LinearAlgebra
extends Object

This class implements some methods from linear algebra (e.g. solution of a linear equation, PCA). It is basically a functional wrapper using either the Colt library or Apache commons math. I am currently preferring to use Colt, due to better performance in some situations, however it allows to easily switch some parts to Apache commons math (this is the motivation for this class).

Version:
1.5
Author:
Christian Fries

Constructor Summary
LinearAlgebra()
           
 
Method Summary
static double[][] factorReduction(double[][] correlationMatrix, int numberOfFactors)
          Returns a correlation matrix which has rank < n and for which the first n factors agree with the factors of correlationMatrix.
static cern.colt.matrix.DoubleMatrix2D factorReductionUsingColt(cern.colt.matrix.DoubleMatrix2D correlationMatrix, int numberOfFactors)
          Returns a correlation matrix which has rank < n and for which the first n factors agree with the factors of correlationMatrix.
static double[][] factorReductionUsingCommonsMath(double[][] correlationMatrix, int numberOfFactors)
          Returns a correlation matrix which has rank < n and for which the first n factors agree with the factors of correlationMatrix.
static double[][] getFactorMatrix(double[][] correlationMatrix, int numberOfFactors)
          Returns the matrix of the n Eigenvectors corresponding to the first n largest Eigenvalues of a correlation matrix.
static double[][] invert(double[][] matrix)
          Returns the inverse of a given matrix.
static double[] solveLinearEquation(double[][] A, double[] b)
          Find a solution of the linear equation A x = b where A is an n x m - matrix given as double[n][m] b is an m - vector given as double[m], x is an n - vector given as double[n],
static double[] solveLinearEquationLeastSquare(double[][] matrix, double[] vector)
          Find a solution of the linear equation A x = b in the least square sense where A is an n x m - matrix given as double[n][m] b is an m - vector given as double[m], x is an n - vector given as double[n],
static double[] solveLinearEquationSymmetric(double[][] matrix, double[] vector)
          Find a solution of the linear equation A x = b where A is an symmetric n x n - matrix given as double[n][n] b is an n - vector given as double[n], x is an n - vector given as double[n],
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearAlgebra

public LinearAlgebra()
Method Detail

solveLinearEquation

public static double[] solveLinearEquation(double[][] A,
                                           double[] b)
Find a solution of the linear equation A x = b where

Parameters:
A - The matrix (left hand side of the linear equation).
b - The vector (right hand of the linear equation).
Returns:
A solution x to A x = b.

invert

public static double[][] invert(double[][] matrix)
Returns the inverse of a given matrix.

Parameters:
matrix - A matrix given as double[n][n].
Returns:
The inverse of the given matrix.

solveLinearEquationSymmetric

public static double[] solveLinearEquationSymmetric(double[][] matrix,
                                                    double[] vector)
Find a solution of the linear equation A x = b where

Parameters:
matrix - The matrix A (left hand side of the linear equation).
vector - The vector b (right hand of the linear equation).
Returns:
A solution x to A x = b.

solveLinearEquationLeastSquare

public static double[] solveLinearEquationLeastSquare(double[][] matrix,
                                                      double[] vector)
Find a solution of the linear equation A x = b in the least square sense where

Parameters:
matrix - The matrix A (left hand side of the linear equation).
vector - The vector b (right hand of the linear equation).
Returns:
A solution x to A x = b.

getFactorMatrix

public static double[][] getFactorMatrix(double[][] correlationMatrix,
                                         int numberOfFactors)
Returns the matrix of the n Eigenvectors corresponding to the first n largest Eigenvalues of a correlation matrix. These Eigenvectors can also be interpreted as "principal components" (i.e., the method implements the PCA).

Parameters:
correlationMatrix - The given correlation matrix.
numberOfFactors - The requested number of factors (eigenvectors).
Returns:
Matrix of n Eigenvectors (columns) (matrix is given as double[n][numberOfFactors], where n is the number of rows of the correlationMatrix.

factorReduction

public static double[][] factorReduction(double[][] correlationMatrix,
                                         int numberOfFactors)
Returns a correlation matrix which has rank < n and for which the first n factors agree with the factors of correlationMatrix.

Parameters:
correlationMatrix - The given correlation matrix.
numberOfFactors - The requested number of factors (Eigenvectors).
Returns:
Factor reduced correlation matrix.

factorReductionUsingCommonsMath

public static double[][] factorReductionUsingCommonsMath(double[][] correlationMatrix,
                                                         int numberOfFactors)
Returns a correlation matrix which has rank < n and for which the first n factors agree with the factors of correlationMatrix.

Parameters:
correlationMatrix - The given correlation matrix.
numberOfFactors - The requested number of factors (Eigenvectors).
Returns:
Factor reduced correlation matrix.

factorReductionUsingColt

public static cern.colt.matrix.DoubleMatrix2D factorReductionUsingColt(cern.colt.matrix.DoubleMatrix2D correlationMatrix,
                                                                       int numberOfFactors)
Returns a correlation matrix which has rank < n and for which the first n factors agree with the factors of correlationMatrix.

Parameters:
correlationMatrix - The given correlation matrix.
numberOfFactors - The requested number of factors (Eigenvectors).
Returns:
Factor reduced correlation matrix.

Copyright © 2014 Christian P. Fries.

Copyright © 2014. All rights reserved.