Skip to content

Commit 39979ce

Browse files
committed
Use free_symbols from C++
1 parent 0384838 commit 39979ce

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

symengine/lib/symengine.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ cdef extern from "<symengine/visitor.h>" namespace "SymEngine":
893893
bool has_symbol(const Basic &b, const Symbol &x) nogil except +
894894
rcp_const_basic coeff(const Basic &b, const Basic &x, const Basic &n) nogil except +
895895
set_basic free_symbols(const Basic &b) nogil except +
896+
set_basic free_symbols(const MatrixBase &b) nogil except +
896897
unsigned count_ops(const vec_basic &a) nogil
897898

898899
cdef extern from "<symengine/logic.h>" namespace "SymEngine":

symengine/lib/symengine_wrapper.pyx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3488,11 +3488,8 @@ cdef class DenseMatrixBase(MatrixBase):
34883488

34893489
@property
34903490
def free_symbols(self):
3491-
s = set()
3492-
for i in range(self.nrows()):
3493-
for j in range(self.ncols()):
3494-
s.update(self._get(i, j).free_symbols)
3495-
return s
3491+
cdef symengine.set_basic _set = symengine.free_symbols(deref(self.thisptr))
3492+
return {c2py(<rcp_const_basic>(elem)) for elem in _set}
34963493

34973494
def _submatrix(self, unsigned r_i, unsigned c_i, unsigned r_j, unsigned c_j, unsigned r_s=1, unsigned c_s=1):
34983495
r_j, c_j = r_j - 1, c_j - 1

0 commit comments

Comments
 (0)