-
Notifications
You must be signed in to change notification settings - Fork 264
Internals: Adding a Library for Interval Arithmetic
Anton Leykin edited this page Sep 17, 2020
·
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).
-
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
Homepage | Projects | Packages | Documentation | Events | Google Group