#20330: hyperbolic_geodesic midpoint bugfix
-------------------------------------+-------------------------------------
Reporter: jhonrubia6 | Owner:
Type: defect | Status: needs_review
Priority: major | Milestone: sage-7.2
Component: geometry | Resolution:
Keywords: hyperbolic | Merged in:
geometry, geodesic | Reviewers: Vincent Delecroix
Authors: Javier Honrubia | Work issues:
González | Commit:
Report Upstream: N/A | 2ba1c96e25d7e128adc832bc4c4e4c51e8835b98
Branch: | Stopgaps:
u/jhonrubia6/hyperbolic_geodesic_midpoint_bugfix|
Dependencies: |
-------------------------------------+-------------------------------------
Comment (by jhonrubia6):
The code
{{{
if isinstance(a, (int,float,complex)): # Python number
a = CDF(a)
if isinstance(a, Expression): # symbolic
P = SR
zero = SR.zero()
one = SR.one()
I = SR("I")
elif isinstance(a, Element): # Sage number
P = a.parent()
zero = P(0) # Get 0 in Parent ring
one = P(1) # Get 1 in Parent ring
CF = CyclotomicField(4) # CF.gen() is guaranteed to
be I
I = P(CF.gen()) # Get I in Parent ring
# In case there is some numerical 'noise'
# e.g. P=CC ; P(CyclotomicField) == 6.123233995736766e-17 +
1.0*I
I = 0.5*(I- I.conjugate())
if I.is_one() or (I*I).is_one() or not (-I*I).is_one():
raise ValueError("invalid number")
else:
raise ValueError("not a complex number")
return matrix(P, 2, [one, zero, zero, -I])
}}}
fails when {{{a = QQbar(1+I)}}} resulting in
{{{
Exception raised:
Traceback (most recent call last):
...
TypeError: Illegal initializer for algebraic number
}}}
The offending code being the {{{matrix(P, 2 [one, zero, zero, -I])}}}
{{{
sage: P = QQbar(1+I).parent()
sage: zero = P(0); one = P(1)
sage: matrix(P, 2, [one, zero, zero, -P(CyclotomicField(4).gen())])
Exception raised:
Traceback (most recent call last):
...
TypeError: Illegal initializer for algebraic number
sage: matrix(P,2,[one,zero,zero,-P.gen()])
[ 1 0]
[ 0 -I]
sage: type(P(CyclotomicField(4).gen()));P(CyclotomicField(4).gen())
<class 'sage.rings.qqbar.AlgebraicNumber'>
I
sage: type(P.gen());P.gen()
<class 'sage.rings.qqbar.AlgebraicNumber'>
I
}}}
Do we have to open a ticket for that and leave this stopped or we leave
the code as it is in the latest commit make it to the release and wait
until the problems with CyclotomicField (numerical noise, and this
particular matrix generation) get solved to open a new ticket on this
module?
IMHO , the commit as it is solves the bug of the ticket (not introducing
any new one) while both of your ideas go into the direction of a
improvement of the code.
--
Ticket URL: <http://trac.sagemath.org/ticket/20330#comment:49>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.