#12101: infinite recursion with exp on sparse matrix
---------------------------------------+------------------------------------
Reporter: benjamin.peterson | Owner: jason, was
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.4
Component: linear algebra | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers: Burcin Erocal
Authors: Karl-Dieter Crisman | Merged in:
Dependencies: | Stopgaps:
---------------------------------------+------------------------------------
Changes (by burcin):
* reviewer: => Burcin Erocal
Comment:
I don't think silently converting the sparse input matrix to a dense one
is a good idea. We should define an `exp()` method for sparse symbolic
matrices to avoid this infinite recursion.
Here is the code for the `exp()` method of `Matrix_symbolic_dense`:
{{{
#!python
def exp(self):
if not self.is_square():
raise ValueError, "exp only defined on square matrices"
if self.nrows() == 0:
return self
# Maxima's matrixexp function chokes on floating point numbers
# so we automatically convert floats to rationals by passing
# keepfloat: false
m = self._maxima_(maxima)
z = maxima('matrixexp(%s), keepfloat: false'%m.name())
if self.nrows() == 1:
# We do the following, because Maxima stupidly exp's 1x1
# matrices into non-matrices!
z = maxima('matrix([%s])'%z.name())
return z._sage_()
}}}
It would be great if we could avoid calling maxima for this. How hard
would it be to implement what maxima does natively in Sage? Here is the
code for the `matrixexp` maxima function:
http://maxima.git.sourceforge.net/git/gitweb.cgi?p=maxima/maxima;a=blob;f=share/linearalgebra/matrixexp.lisp;hb=HEAD
Another option is to find a way to convert a sparse matrix to Maxima and
still use its `matrixexp()` implementation. Does Maxima have a sparse
matrix constructor?
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12101#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.