Skip to content

Commit 2ca28c1

Browse files
authored
Merge pull request #262 from isuruf/free_symbol
Use free_symbols from C++
2 parents fbaa444 + 39979ce commit 2ca28c1

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
@@ -3496,11 +3496,8 @@ cdef class DenseMatrixBase(MatrixBase):
34963496

34973497
@property
34983498
def free_symbols(self):
3499-
s = set()
3500-
for i in range(self.nrows()):
3501-
for j in range(self.ncols()):
3502-
s.update(self._get(i, j).free_symbols)
3503-
return s
3499+
cdef symengine.set_basic _set = symengine.free_symbols(deref(self.thisptr))
3500+
return {c2py(<rcp_const_basic>(elem)) for elem in _set}
35043501

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

0 commit comments

Comments
 (0)