Skip to content

Commit cbb74fc

Browse files
committed
fixes #147
1 parent e3f4bd2 commit cbb74fc

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

symengine/lib/symengine_wrapper.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1940,9 +1940,12 @@ cdef class DenseMatrixBase(MatrixBase):
19401940
def _applyfunc(self, f):
19411941
cdef int nr = self.nrows()
19421942
cdef int nc = self.ncols()
1943+
cdef Basic e_;
19431944
for i in range(nr):
19441945
for j in range(nc):
1945-
self._set(i, j, f(self._get(i, j)))
1946+
e_ = _sympify(f(self._get(i, j)))
1947+
if e_ is not None:
1948+
deref(self.thisptr).set(i, j, e_.thisptr)
19461949

19471950
def applyfunc(self, f):
19481951
cdef DenseMatrixBase out = self.__class__(self)

symengine/tests/test_matrices.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,8 @@ def test_immutablematrix():
395395
X = ImmutableMatrix([[1, 2], [3, 4]])
396396
Y = ImmutableMatrix([[1], [0]])
397397
assert type(X.LUsolve(Y)) == ImmutableMatrix
398+
399+
x = Symbol("x")
400+
X = ImmutableMatrix([[1, 2], [3, 4]])
401+
Y = ImmutableMatrix([[1, 2], [x, 4]])
402+
assert Y.subs(x, 3) == X

0 commit comments

Comments
 (0)