- 
                Notifications
    You must be signed in to change notification settings 
- Fork 259
Internals: Adding a Library for Interval Arithmetic
        Anton Leykin edited this page Mar 23, 2021 
        ·
        7 revisions
      
    This documents a way to add mpfi to the arsenal of M2. Perhaps also arb.
We can work by analogy with mpfr.
Before starting, check the license compatibility: some version of GPL is usually OK.
- Modify M2/INSTALL.
- 
M2/configure.ac- Get mpfionLIBLIST
- Check that mpfi.his in order: search forAC_CHECK_HEADERandmpfrto see an example. (The libraries appear in order of dependency: more dependent first, more independent last. So-lmpfishould be go before-lmpfr.)
 
- Get 
- Create M2/libraries/mpfi/Makefile.in(modify a copy ofM2/libraries/mpfr/Makefile.in)
- Make sure you run makeinM2/after modifyingconfigure.acand any of theMakefile.infiles.
- 
grep -r mpfr M2/Macaulay2/*to see where in source codempfris used.- e.g. d/version.ddhas"mpfr version" => Ccode(constcharstar,"mpfr_version")
 
- e.g. 
- dichotomy in memory allocation (native vs. garbage collected): see d/gmp.dfor comment starting with--We introduce to types...
- Create something analogous to RRcell(seeparse.d)
- Compare raw RR_100andraw RR_53(53=standard precision)
- 
rawRRininterface.ddwrapsIM2_Ring_RRR--- make something like that: e.g. createrawRRithat wrapsrawRingRRi
- 
IM2_Ring_RRRis inengine.handx-relem.cpp. Inspect the code in the latter.
- Look at aring-RRR.hpp- Engine's ARings are fast implementations of "coefficient rings". (A polynomial ring is not an ARing. Seearing.hppforDummyRing--- all methods mentioned there need to be implemented.)
- Create aring-RRi.hpp--- this will houseARingRRi.
- In aring.hpp, addring_RRiand setring_top = 17
- No worries about memory allocation --- assume all memory is getting allocated without GC, unless gmp_RRgets involved.
 
- Engine's 
- Look at aring-glue.hpp(no need to make changes here --- just be aware that this is a place whereARings get used).- 
ring_elemoperations are handled here (at the moment,ring_elemis GC-ed).
 
- 
The summary of this commit:
- add 1 line to config/files
- in configure.acmentionmpfiin help for--enable-build-librariesoptions
- write libraries/mpfi/Makefile.in
Detailed instructions are here.
- 
ExternalProject_Addis what we need to addmpfi(modify the corresponding block incmake/build-libraries.cmakeformpfr).- There are several steps in setting up an external project: e.g. CONFIGURE_COMMANDcontrols the "configure" step,BUILD_COMMANDthe building, etc.
- 
_ADD_COMPONENT_DEPENDENCYto declarempfidependencies.
 
- There are several steps in setting up an external project: e.g. 
- Modify cmake/check-libraries.cmakeandcmake/FindMPFI.cmakeaccordingly.
(Michael Burr and Anton Leykin)
- changes in d/involveclasses.dd,expr.d,actors2.dd,equality.dd,parse.d,gmp.d,gmp_aux.[h,c]- introduce RRi,RRimutable,RRiClass
- copy-paste RRversions of methods (with minimal edits) whenever errors pop up during a build.
 
- introduce 
- 
gmp.dhandlingRRi,RRimutable:- 
leftRRandrightRRget the left/right ends of the interval
- input methods
- arithmetic operations
- comparison operations
 
- 
- 
util.d- toExpr
 
- 
gmp1.d- tostringRRi
 
- 
interface.dd- 
rawToRRi(is it used anywhere? see.toRRi)
 
- 
- 
actors.d- arithmetic on the level of Expr
 
- arithmetic on the level of 
- 
actors3.d- round0(e:Expr):Expr
 
- 
actors4.d- 
interval(constructor)
- 
toRRi,toRR,toCC, etc. (forExpr)
 
- 
- 
real.m2handles theInexactFieldcalledRRi
- 
exports.m2exportsRRi,RRi',toRRi,interval
- raw rings/elements (general): m2/engine.m2
- single (raw/front) ring elements: m2/reals.m2
- matrices/lists (general): m2/modules.m2, usesrawPromote
General questions:
- How should promoteandliftwork for intervals?- What is the philosophy for RR_*?
 
- What is the philosophy for 
- What is the expected behavior of new ... from ...?
- Macaulay2/normal/RRi.m2
- Should there be any g-tests?
- What tests get executed when building M2?
Homepage | Projects | Packages | Documentation | Events | Google Group