Open fph opened 9 years ago
Random thought: would it be possible to alter the behaviour of max(x,y)
, to have it do the right thing or at least return error? It's a Python built-in, so I suspect the answer is "no, or we would have done it long ago".
If the behaviour of max cannot be changed, can it be forbidden in sage (e.g. by preparsing or whatever) to use pythons max()?
Stopgaps: wrongAnswerMarker
I remember having this issue a long time ago. I had then made the following fix which seemed to work after some quick local tests :
diff --git a/src/sage/modules/free_module_element.pyx b/src/sage/modules/free_module_element.pyx
index 3492dbf2eb..23e06326fd 100644
--- a/src/sage/modules/free_module_element.pyx
+++ b/src/sage/modules/free_module_element.pyx
@@ -1753,9 +1753,11 @@ cdef class FreeModuleElement(Vector): # abstract base class
sage: v.norm(int(2)) # needs sage.symbolic
sqrt(5)
"""
+ from sage.functions.min_max import max_symbolic
+
abs_self = [abs(x) for x in self]
if p == Infinity:
- return max(abs_self)
+ return max_symbolic(abs_self)
if p < 1:
raise ValueError("%s is not greater than or equal to 1" % p)
Could this be a solution ?
As documented in http://www.sagemath.org/doc/reference/rings_numerical/sage/rings/real_mpfi.html#sage.rings.real_mpfi.RealIntervalFieldElement.max,
max(I,J)
does not do the correct thing for real intervals, andI.max(J)
has to be used instead.When computing the infinity norm of a vector of real intervals, the wrong version of
max
gets used, though:CC: @sagetrac-jakobkroeker
Component: linear algebra
Stopgaps: wrongAnswerMarker
Issue created by migration from https://trac.sagemath.org/ticket/17728