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

mikera.matrixx.decompose.impl.lu.LUPResult 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.lu;

import mikera.matrixx.AMatrix;
import mikera.matrixx.decompose.ILUPResult;
import mikera.matrixx.impl.PermutationMatrix;

public class LUPResult implements ILUPResult {
	final AMatrix l;
	final AMatrix u;
	final PermutationMatrix p;

	public LUPResult(AMatrix l, AMatrix u, PermutationMatrix p) {
		this.l=l;
		this.u=u;
		this.p=p;
	}
	
	public LUPResult(AMatrix l, AMatrix u) {
		this (l,u,PermutationMatrix.createIdentity(l.rowCount()));
	}

	@Override
	public AMatrix getL() {
		return l;
	}

	@Override
	public AMatrix getU() {
		return u;
	}

	@Override
	public PermutationMatrix getP() {
		return p;
	}

	@Override
	public double computeDeterminant() {
		if (l.rowCount()!= u.columnCount()) {
			throw new IllegalArgumentException("Input must be a square matrix");
		}
		return u.diagonalProduct()*p.determinant();
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy