-
Notifications
You must be signed in to change notification settings - Fork 236
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
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).
-
The summary of this commit:
- add 1 line to
config/files
- in
configure.ac
mentionmpfi
in help for--enable-build-libraries
options - write
libraries/mpfi/Makefile.in
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
-
gmp.d
handlingRRi
,RRimutable
:-
leftRR
andrightRR
get 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.m2
handles theInexactField
calledRRi
-
exports.m2
exportsRRi
,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
promote
andlift
work 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