mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
fixes #178
This commit is contained in:
parent
1ae4bba960
commit
7a5f75eedc
|
|
@ -44,10 +44,45 @@ class LUDecompositionTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
$vec = new Vector();
|
||||
$vec->setMatrix([[40], [49], [28]]);
|
||||
self::assertTrue($lu->isNonSingular());
|
||||
self::assertEquals([[1], [2], [3]], $lu->solve($vec)->toArray(), '', 0.2);
|
||||
self::assertEquals([0, 1, 2], $lu->getPivot());
|
||||
}
|
||||
|
||||
public function testSingularMatrix()
|
||||
{
|
||||
$B = new Matrix();
|
||||
$B->setMatrix([
|
||||
[25, 15, -5],
|
||||
[0, 0, 1],
|
||||
[0, 0, 2],
|
||||
]);
|
||||
|
||||
$lu = new LUDecomposition($B);
|
||||
|
||||
self::assertFalse($lu->isNonSingular());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testSolveOfSingularMatrix()
|
||||
{
|
||||
$B = new Matrix();
|
||||
$B->setMatrix([
|
||||
[25, 15, -5],
|
||||
[0, 0, 1],
|
||||
[0, 0, 2],
|
||||
]);
|
||||
|
||||
$lu = new LUDecomposition($B);
|
||||
|
||||
$vec = new Vector();
|
||||
$vec->setMatrix([[40], [49], [28]]);
|
||||
|
||||
$lu->solve($vec);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \phpOMS\Math\Matrix\Exception\InvalidDimensionException
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user