-
-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #24511: Move create_RealField to real_field.py
This is part of #24457 but it already makes sense without that ticket to have the factory function in a separate module. URL: https://trac.sagemath.org/24511 Reported by: rws Ticket author(s): Ralf Stephan Reviewer(s): Vincent Delecroix
- Loading branch information
Showing
4 changed files
with
82 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
def create_RealField(prec=53, type="MPFR", rnd="RNDN", sci_not=0): | ||
""" | ||
Create a real field with given precision, type, rounding mode and | ||
scientific notation. | ||
Some options are ignored for certain types (RDF for example). | ||
INPUT: | ||
- ``prec`` -- a positive integer | ||
- ``type`` -- type of real field: | ||
- ``'RDF'`` -- the Sage real field corresponding to native doubles | ||
- ``'Interval'`` -- real fields implementing interval arithmetic | ||
- ``'RLF'`` -- the real lazy field | ||
- ``'MPFR'`` -- floating point real numbers implemented using the MPFR | ||
library | ||
- ``rnd`` -- rounding mode: | ||
- ``'RNDN'`` -- round to nearest | ||
- ``'RNDZ'`` -- round toward zero | ||
- ``'RNDD'`` -- round down | ||
- ``'RNDU'`` -- round up | ||
- ``sci_not`` -- boolean, whether to use scientific notation for printing | ||
OUTPUT: | ||
the appropriate real field | ||
EXAMPLES:: | ||
sage: from sage.rings.real_field import create_RealField | ||
sage: create_RealField(30) | ||
Real Field with 30 bits of precision | ||
sage: create_RealField(20, 'RDF') # ignores precision | ||
Real Double Field | ||
sage: create_RealField(60, 'Interval') | ||
Real Interval Field with 60 bits of precision | ||
sage: create_RealField(40, 'RLF') # ignores precision | ||
Real Lazy Field | ||
""" | ||
if type == "RDF": | ||
from .real_double import RDF | ||
return RDF | ||
elif type == "Interval": | ||
from .real_mpfi import RealIntervalField | ||
return RealIntervalField(prec, sci_not) | ||
elif type == "Ball": | ||
from .real_arb import RealBallField | ||
return RealBallField(prec) | ||
elif type == "RLF": | ||
from .real_lazy import RLF | ||
return RLF | ||
else: | ||
from .real_mpfr import RealField | ||
return RealField(prec, sci_not, rnd) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters