Skip to content

Commit

Permalink
Add LUDecomposition triangular factor tests (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
marmichalski authored and akondas committed Mar 4, 2018
1 parent 941d240 commit 33efab2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/Math/LinearAlgebra/LUDecompositionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,22 @@ public function testSolveWithInvalidMatrix(): void
$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());
}
}

0 comments on commit 33efab2

Please sign in to comment.