Skip to content

Commit 05ee644

Browse files
committed
Test QR and cholesky
These are the same as the ones recently merged into symengine. Signed-off-by: Connor Behan <[email protected]>
1 parent a9c40b4 commit 05ee644

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

symengine/tests/test_matrices.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from symengine import symbols
22
from symengine.lib.symengine_wrapper import (DenseMatrix, Symbol, Integer,
3-
function_symbol, I, NonSquareMatrixError, ShapeError, zeros, ones, eye,
4-
ImmutableMatrix)
3+
Rational, function_symbol, I, NonSquareMatrixError, ShapeError, zeros,
4+
ones, eye, ImmutableMatrix)
55
from symengine.utilities import raises
66

77

@@ -353,6 +353,25 @@ def test_FFLDU():
353353
assert U == DenseMatrix(3, 3, [1, 2, 3, 0, -13, -13, 0, 0, 91])
354354

355355

356+
def test_QR():
357+
A = DenseMatrix(3, 3, [12, -51, 4, 6, 167, -68, -4, 24, -41])
358+
Q, R = A.QR()
359+
360+
assert Q == DenseMatrix(3, 3, [Rational(6, 7), Rational(-69, 175),
361+
Rational-58, 175), Rational(3, 7),
362+
Rational(158, 175), Rational(6, 175),
363+
Rational(-2, 7), Rational(6, 35),
364+
Rational(-33, 35)])
365+
assert R == DenseMatrix(3, 3, [14, 21, -14, 0, 175, -70, 0, 0, 35])
366+
367+
368+
def test_cholesky():
369+
A = DenseMatrix(3, 3, [4, 12, -16, 12, 37, -43, -16, -43, 98])
370+
L = A.cholesky()
371+
372+
assert L == DenseMatrix(3, 3, [2, 0, 0, 6, 1, 0, -8, 5, 3])
373+
374+
356375
def test_str_repr():
357376
d = DenseMatrix(3, 2, [1, 2, 3, 4, 5, 6])
358377
assert str(d) == '[1, 2]\n[3, 4]\n[5, 6]\n'

0 commit comments

Comments
 (0)