-
Notifications
You must be signed in to change notification settings - Fork 227
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
mpfi
onLIBLIST
- Check that
mpfi.h
is in order: search forAC_CHECK_HEADER
andmpfr
to see an example. (The libraries appear in order of dependency: more dependent first, more independent last. So-lmpfi
should be go before-lmpfr
.)
- Get
- Create
M2/libraries/mpfi/Makefile.in
(modify a copy ofM2/libraries/mpfr/Makefile.in
) - Make sure you run
make
inM2/
after modifyingconfigure.ac
and any of theMakefile.in
files. -
grep -r mpfr M2/Macaulay2/*
to see where in source codempfr
is used.- e.g.
d/version.dd
has"mpfr version" => Ccode(constcharstar,"mpfr_version")
- e.g.
- dichotomy in memory allocation (native vs. garbage collected): see
d/gmp.d
for comment starting with--We introduce to types...
- Create something analogous to
RRcell
(seeparse.d
)
- Compare
raw RR_100
andraw RR_53
(53=standard precision) -
rawRR
ininterface.dd
wrapsIM2_Ring_RRR
--- make something like that: e.g. createrawRRi
that wrapsrawRingRRi
-
IM2_Ring_RRR
is inengine.h
andx-relem.cpp
. Inspect the code in the latter. - Look at
aring-RRR.hpp
- Engine's
ARing
s are fast implementations of "coefficient rings". (A polynomial ring is not an ARing. Seearing.hpp
forDummyRing
--- all methods mentioned there need to be implemented.) - Create
aring-RRi.hpp
--- this will houseARingRRi
. - In
aring.hpp
, addring_RRi
and setring_top = 17
- No worries about memory allocation --- assume all memory is getting allocated without GC, unless
gmp_RR
gets involved.
- Engine's
- Look at
aring-glue.hpp
(no need to make changes here --- just be aware that this is a place whereARing
s get used).-
ring_elem
operations are handled here (at the moment,ring_elem
is GC-ed).
-
Detailed instructions are here.
-
ExternalProject_Add
is what we need to addmpfi
(modify the corresponding block incmake/build-libraries.cmake
formpfr
).- There are several steps in setting up an external project: e.g.
CONFIGURE_COMMAND
controls the "configure" step,BUILD_COMMAND
the building, etc. -
_ADD_COMPONENT_DEPENDENCY
to declarempfi
dependencies.
- There are several steps in setting up an external project: e.g.
- Modify
cmake/check-libraries.cmake
andcmake/FindMPFI.cmake
accordingly.
(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
RR
versions of methods (with minimal edits) whenever errors pop up during a build.
- introduce
Homepage | Projects | Packages | Documentation | Events | Google Group