Skip to content

Commit a9c40b4

Browse files
committed
Expose more matrix factorizations
We can add support for QR and cholesky with recent symengine versions.
1 parent 7643152 commit a9c40b4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

symengine/lib/symengine.pxd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,9 @@ cdef extern from "<symengine/matrix.h>" namespace "SymEngine":
789789
void LDL(MatrixBase &L, MatrixBase &D) nogil
790790
void LU_solve(const MatrixBase &b, MatrixBase &x) nogil
791791
void FFLU(MatrixBase &LU) nogil
792-
void FFLDU(MatrixBase&L, MatrixBase &D, MatrixBase &U) nogil
792+
void FFLDU(MatrixBase &L, MatrixBase &D, MatrixBase &U) nogil
793+
void QR(MatrixBase &Q, MatrixBase &R) nogil
794+
void cholesky(MatrixBase &L) nogil
793795

794796
cdef cppclass DenseMatrix(MatrixBase):
795797
DenseMatrix()

symengine/lib/symengine_wrapper.pyx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3604,6 +3604,17 @@ cdef class DenseMatrixBase(MatrixBase):
36043604
deref(self.thisptr).FFLDU(deref(L.thisptr), deref(D.thisptr), deref(U.thisptr))
36053605
return L, D, U
36063606

3607+
def QR(self):
3608+
cdef DenseMatrixBase Q = self.__class__(self.nrows(), self.ncols())
3609+
cdef DenseMatrixBase R = self.__class__(self.nrows(), self.ncols())
3610+
deref(self.thisptr).QR(deref(Q.thisptr), deref(R.thisptr))
3611+
return Q, R
3612+
3613+
def cholesky(self):
3614+
cdef DenseMatrixBase L = self.__class__(self.nrows(), self.ncols())
3615+
deref(self.thisptr).cholesky(deref(L.thisptr))
3616+
return L
3617+
36073618
def jacobian(self, x):
36083619
cdef DenseMatrixBase x_ = sympify(x)
36093620
cdef DenseMatrixBase R = self.__class__(self.nrows(), x.nrows())

0 commit comments

Comments
 (0)