Add LUDecomposition triangular factor tests (#253)

This commit is contained in:
Marcin Michalski 2018-03-04 17:05:25 +01:00 committed by Arkadiusz Kondas
parent 941d240ab6
commit 33efab20a5

View File

@ -28,4 +28,22 @@ final class LUDecompositionTest extends TestCase
$lu = new LUDecomposition(new Matrix([[1, 2], [3, 4]]));
$lu->solve(new Matrix([1, 2, 3]));
}
public function testLowerTriangularFactor(): void
{
$lu = new LUDecomposition(new Matrix([[1, 2], [3, 4]]));
$L = $lu->getL();
$this->assertInstanceOf(Matrix::class, $L);
$this->assertSame([[1.0, 0.0], [0.3333333333333333, 1.0]], $L->toArray());
}
public function testUpperTriangularFactor(): void
{
$lu = new LUDecomposition(new Matrix([[1, 2], [3, 4]]));
$U = $lu->getU();
$this->assertInstanceOf(Matrix::class, $U);
$this->assertSame([[3.0, 4.0], [0.0, 0.6666666666666667]], $U->toArray());
}
}