|
1 | 1 | from symengine import symbols
|
2 | 2 | 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) |
5 | 5 | from symengine.utilities import raises
|
6 | 6 |
|
7 | 7 |
|
@@ -353,6 +353,25 @@ def test_FFLDU():
|
353 | 353 | assert U == DenseMatrix(3, 3, [1, 2, 3, 0, -13, -13, 0, 0, 91])
|
354 | 354 |
|
355 | 355 |
|
| 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 | + |
356 | 375 | def test_str_repr():
|
357 | 376 | d = DenseMatrix(3, 2, [1, 2, 3, 4, 5, 6])
|
358 | 377 | assert str(d) == '[1, 2]\n[3, 4]\n[5, 6]\n'
|
|
0 commit comments