Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maxima from the OS #35615

Closed
wants to merge 11 commits into from
5 changes: 1 addition & 4 deletions build/pkgs/ecl/spkg-configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ SAGE_SPKG_CONFIGURE([ecl], [
AC_SUBST(SAGE_ECL_CONFIG, [$ECL_CONFIG])
fi

# Maxima cannot yet be provided by the system, so we always use
# Kenzo cannot yet be provided by the system, so we always use
# the SAGE_LOCAL path for now.
AC_SUBST(SAGE_MAXIMA_FAS, ['${prefix}'/lib/ecl/maxima.fas])

# Likewise for the optional Kenzo SPKG
AC_SUBST(SAGE_KENZO_FAS, ['${prefix}'/lib/ecl/kenzo.fas])
])
2 changes: 1 addition & 1 deletion build/pkgs/maxima/distros/arch.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
maxima-ecl
maxima-fas
1 change: 1 addition & 0 deletions build/pkgs/maxima/distros/cygwin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
maxima
1 change: 1 addition & 0 deletions build/pkgs/maxima/distros/freebsd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
math/maxima
2 changes: 2 additions & 0 deletions build/pkgs/maxima/distros/gentoo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sci-mathematics/maxima[ecls]

32 changes: 32 additions & 0 deletions build/pkgs/maxima/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
SAGE_SPKG_CONFIGURE([maxima], [
SAGE_SPKG_DEPCHECK([ecl], [
dnl First check for the "maxima" executable in the user's PATH, because
dnl we still use pexpect to communicate with it in a few places.
AC_PATH_PROG([SAGE_MAXIMA], [maxima])
AS_IF([test -z "${SAGE_MAXIMA}"], [
sage_spkg_install_maxima=yes
],[
dnl If we have the executable, check also for the ECL library.
AC_MSG_CHECKING([if ECL can "require" the maxima module])
AS_IF([ecl --eval "(require 'maxima)" --eval "(quit)" \
>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
sage_spkg_install_maxima=yes
])
])
])
],[],[],[
# post-check
AS_IF([test x$sage_spkg_install_maxima = xyes], [
dnl Leaving this variable empty will tell sagelib to load
dnl the maxima library (within ECL) by name instead of by
dnl absolute path.
SAGE_MAXIMA='${prefix}'/bin/maxima
SAGE_MAXIMA_FAS='${prefix}'/lib/ecl/maxima.fas
])

AC_SUBST(SAGE_MAXIMA, "${SAGE_MAXIMA}")
AC_SUBST(SAGE_MAXIMA_FAS, "${SAGE_MAXIMA_FAS}")
])
6 changes: 4 additions & 2 deletions pkgs/sage-conf/_sage_conf/_conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ VERSION = "@PACKAGE_VERSION@"
SAGE_LOCAL = "@prefix@"
SAGE_ROOT = "@SAGE_ROOT@"

MAXIMA = "@prefix@/bin/maxima"
# The path to the standalone maxima executable.
MAXIMA = "@SAGE_MAXIMA@".replace('${prefix}', SAGE_LOCAL)

# Delete this line if your ECL can load maxima without further prodding.
# Set this to the empty string if your ECL can load maxima without
# further prodding.
MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)

# Delete this line if your ECL can load Kenzo without further prodding.
Expand Down
3 changes: 0 additions & 3 deletions src/bin/sage-env
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,6 @@ if [ -d "$DOT_SAGE" ] ; then
fi
fi

if [ -n "$SAGE_LOCAL" ]; then
export MAXIMA_PREFIX="$SAGE_LOCAL"
fi
export MAXIMA_USERDIR="$DOT_SAGE/maxima"

if [ -n "$SAGE_LOCAL" ]; then
Expand Down
5 changes: 3 additions & 2 deletions src/sage/calculus/calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,11 @@
[ 1/2*(e^(2*sqrt(x)) + 1)*e^(x - sqrt(x)) 1/2*(x*e^(2*sqrt(x)) - x)*sqrt(x)*e^(x - sqrt(x))]
[ 1/2*(e^(2*sqrt(x)) - 1)*e^(x - sqrt(x))/x^(3/2) 1/2*(e^(2*sqrt(x)) + 1)*e^(x - sqrt(x))]

And complex exponentiation works now::
Complex exponentiation works, but may require a patched version of
maxima (:trac:`32898`) for now::

sage: M = i*matrix([[pi]])
sage: e^M
sage: e^M # not tested, requires patched maxima
[-1]
sage: M = i*matrix([[pi,0],[0,2*pi]])
sage: e^M
Expand Down
2 changes: 1 addition & 1 deletion src/sage/interfaces/expect.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def quit(self, verbose=False):

sage: a = maxima('y')
sage: maxima.quit(verbose=True)
Exiting Maxima with PID ... running .../bin/maxima...
Exiting Maxima with PID ... running ...maxima...
sage: a._check_valid()
Traceback (most recent call last):
...
Expand Down
8 changes: 0 additions & 8 deletions src/sage/interfaces/maxima.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,21 +622,13 @@ def _start(self):
sage: m.is_running()
True

Test that we can use more than 256MB RAM (see :trac:`6772`)::

sage: a = maxima(10)^(10^5)
sage: b = a^600 # long time -- about 10-15 seconds

"""
Expect._start(self)
self._sendline(r":lisp (defun tex-derivative (x l r) (tex (if $derivabbrev (tex-dabbrev x) (tex-d x '\\partial)) l r lop rop ))")

# Don't use ! for factorials (#11539)
self._sendline(":lisp (remprop 'mfactorial 'grind)")

# Remove limit on the max heapsize (since otherwise it defaults
# to 256MB with ECL).
self._sendline(":lisp (ext:set-limit 'ext:heap-size 0)")
self._eval_line('0;')

# set random seed
Expand Down
5 changes: 3 additions & 2 deletions src/sage/matrix/matrix2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15425,9 +15425,10 @@ cdef class Matrix(Matrix1):

TESTS:

Check that sparse matrices are handled correctly (:trac:`28935`)::
Sparse matrices are handled correctly (:trac:`28935`), but may
require a patched version of maxima (:trac:`32898`) for now::

sage: matrix.diagonal([0], sparse=True).exp()
sage: matrix.diagonal([0], sparse=True).exp() # not tested, requires patched maxima
[1]
sage: matrix.zero(CBF, 2, sparse=True).exp()
[1.000000000000000 0]
Expand Down
6 changes: 3 additions & 3 deletions src/sage/matrix/matrix_symbolic_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,16 @@ cdef class Matrix_symbolic_dense(Matrix_generic_dense):
[1/2*(e^(2*x) + 1)*e^(-x) 1/2*(e^(2*x) - 1)*e^(-x)]
[1/2*(e^(2*x) - 1)*e^(-x) 1/2*(e^(2*x) + 1)*e^(-x)]

Exp works on 0x0 and 1x1 matrices::
Exponentiation works on 0x0 and 1x1 matrices, but the 1x1 example
requires a patched version of maxima (:trac:`32898`) for now::

sage: m = matrix(SR,0,[]); m
[]
sage: m.exp()
[]
sage: m = matrix(SR,1,[2]); m
[2]
sage: m.exp()
sage: m.exp() # not tested, requires patched maxima
[e^2]

Commuting matrices `m, n` have the property that
Expand Down Expand Up @@ -451,7 +452,6 @@ cdef class Matrix_symbolic_dense(Matrix_generic_dense):
[ 0 1/2*(e^(2*x) + 1)*e^(-x) 1/2*(e^(2*x) - 1)*e^(-x) 0]
[ 0 1/2*(e^(2*x) - 1)*e^(-x) 1/2*(e^(2*x) + 1)*e^(-x) 0]
[1/2*(e^(2*x) - 1)*e^(-x) 0 0 1/2*(e^(2*x) + 1)*e^(-x)]

"""
if not self.is_square():
raise ValueError("exp only defined on square matrices")
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/real_double.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ cdef class RealDoubleElement(FieldElement):
def round(self):
"""
Round ``self`` to the nearest integer.

This uses the convention of rounding half to even
(i.e., if the fractional part of ``self`` is `0.5`, then it
is rounded to the nearest even integer).
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/real_mpfr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2992,7 +2992,7 @@ cdef class RealNumber(sage.structure.element.RingElement):
"""
Round ``self`` to the nearest representable integer, rounding halfway
cases away from zero.

.. NOTE::

The rounding mode of the parent field does not affect the result.
Expand Down