#13110: ComplexNumber should be able to accept the Python complex type
-------------------------------------+--------------------------------------
Reporter: eviatarbach | Owner: jason, jkantor
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.10
Component: numerical | Resolution:
Keywords: complex, beginner | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Travis Scrimshaw | Merged in:
Dependencies: | Stopgaps:
-------------------------------------+--------------------------------------
Comment (by nbruin):
Replying to [comment:15 vbraun]:
> `CC._element_constructor_` is probably slow for string input since it
evaluates the input. I'm a bit uncomfortable with that security-wise,
though there are certainly bigger fish to fry.
Yes, indeed. That very "eval" instruction is marked with a "TODO",
indicating that it could use improvements. I'd say that's the place to a
string interpretation routine, rather than in `create_ComplexNumber`.
Note, by the way, that most machinery for making complex numbers sits in
`sage.rings.complex_number.ComplexNumber.__init__`. It can deal with
various inputs, including strings for real and imag, by virtue of just
calling `RR(real)` and `RR(imag)` (where `RR` is the underlying real
field). Thus, the only thing a "complex number" parser would have to do is
locate the likely real and imaginary part in the string and pass them on.
This could even be put in this routine itself.
There is one thing that `create_ComplexNumber` does that other routines
don't: It takes the string lengths as an indication of the number of bits
required in the representation. None of the other routines do that. It
also indicates that `create_ComplexNumber` perhaps shouldn't be used for
anything more general, or in its other roles, take a hint from its input
to choose what precision to use.
I think in general, guessing precision from number of digits written down
is rarely going to produce desirable results, so I'd be for providing the
user interface with a default precision (complex) field.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13110#comment:17>
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 http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.