-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
e7d43bd
commit 1ead3e5
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python | ||
|
||
# Codac tests | ||
# ---------------------------------------------------------------------------- | ||
# \date 2024 | ||
# \author Damien Massé | ||
# \copyright Copyright 2024 Codac Team | ||
# \license GNU Lesser General Public License (LGPL) | ||
|
||
|
||
import unittest | ||
from codac import * | ||
|
||
class TestIntFullPivLU(unittest.TestCase): | ||
|
||
|
||
# bindings not implemented | ||
def tests_IntFullPivLU_1(self): | ||
M = Matrix([ | ||
[ 1, -4, 3, 7 ], | ||
[ 2, 1, -4, 6 ], | ||
[ 5, 2, 1 , 9 ], | ||
[ -1, 0, 3, 2 ] | ||
]) | ||
|
||
LUdec = IntFullPivLU(M) | ||
self.assertTrue(LUdec.isInjective()==BoolInterval.TRUE) | ||
self.assertTrue(LUdec.isSurjective()==BoolInterval.TRUE) | ||
self.assertTrue(LUdec.rank()==Interval(4)) | ||
self.assertTrue((LUdec.determinant()+602).mag()<=1e-10) | ||
self.assertTrue((LUdec.ReconstructedMatrix()-M).norm().ub()<=1e-10) | ||
I1 = LUdec.solve(IntervalMatrix.eye(4,4)); | ||
self.assertTrue((I1*M-Matrix.eye(4,4)).norm().ub()<1e-10) | ||
|
||
def tests_IntFullPivLU_2(self): | ||
M = Matrix([ | ||
[ 1, -4, 6, 7 ], | ||
[ 2, 1, 3, 6 ], | ||
[ 5, 2, 8 , 9 ], | ||
[ -1, 0, -2, 2 ] | ||
]) | ||
|
||
LUdec = IntFullPivLU(M) | ||
self.assertTrue(LUdec.isInjective()==BoolInterval.UNKNOWN) | ||
self.assertTrue(LUdec.isSurjective()==BoolInterval.UNKNOWN) | ||
self.assertTrue(LUdec.rank()==Interval([3,4])) | ||
self.assertTrue((LUdec.determinant()).mag()<=1e-10) | ||
self.assertTrue((LUdec.ReconstructedMatrix()-M).norm().ub()<=1e-10) | ||
K = LUdec.kernel() | ||
self.assertTrue(K.cols()==1) | ||
self.assertTrue((M*K).norm().ub()<1e-10) | ||
Im = LUdec.image(M) | ||
self.assertTrue(Im.cols()==3) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |