All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mikera.matrixx.decompose.impl.chol.SimpleCholesky Maven / Gradle / Ivy

Go to download

Fast double-precision vector and matrix maths library for Java, supporting N-dimensional numeric arrays.

There is a newer version: 0.67.0
Show newest version
package mikera.matrixx.decompose.impl.chol;

import mikera.matrixx.AMatrix;
import mikera.matrixx.Matrix;
import mikera.matrixx.Matrixx;
import mikera.matrixx.decompose.ICholeskyResult;
import mikera.util.Maths;

/**
 * Class implementing a standard Cholesky decomposition
 * 
 *    A = L.L*
 *    
 * Where: A  is a symmetric (actually Hermitian), positive-definite matrix 
 * and:   L  is a lower triangular matrix
 *        L* is the conjugate transpose of L (which is equal to its transpose, since A is real in Vectorz)
 * 
 * See: http://en.wikipedia.org/wiki/Cholesky_decomposition
 * 
 * @author Mike
 *
 */
public class SimpleCholesky {

	private SimpleCholesky(){}

	/**
	 * Decompose a matrix according the the Cholesky decomposition A = L.L*
	 * 
	 * @param a Any symmetric, positive definite matrix
	 * @return The decomposition result
	 */
	public static final ICholeskyResult decompose(AMatrix a) {
		return decompose(a.toMatrix());
	}
	
	public static final ICholeskyResult decompose(Matrix a) {
		if (!a.isSquare()) throw new IllegalArgumentException("Matrix must be square for Cholesky decomposition");
		int n=a.rowCount();
		
		Matrix u=Matrix.create(n,n);
		for (int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy