Skip to content

Commit 32334f1

Browse files
authored
Merge pull request #7 from wegank/raglib-install-1
Add installation script
2 parents 8ddd497 + 6e3722c commit 32334f1

5 files changed

Lines changed: 2123 additions & 2014 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ Source code and installation instructions for
4545
## Basic usage
4646

4747
At the moment, `RAGlib` provides two main functions:
48-
- `HasRealSolutions(eqs, pos, ineqs)` where eqs, pos, ineqs are lists
48+
- `RAG[HasRealSolutions](eqs, pos, ineqs)` where eqs, pos, ineqs are lists
4949
of polynomials encoding equality, positivity and non-vanishing
5050
constraints respectively.
5151
It decides whether the set of real solutions to the input
5252
constraints is empty or not. In case of emptiness, it returns an
5353
empty list, otherwise, it returns a list of witness points.
5454
All such points are encoded by isolating boxes.
55-
- `PointsPerComponents(eqs, pos, ineqs)` where eqs, pos, ineqs are lists
55+
- `RAG[PointsPerComponents](eqs, pos, ineqs)` where eqs, pos, ineqs are lists
5656
of polynomials encoding equality, positivity and non-vanishing
5757
constraints respectively.
5858
It returns a list of points (encoded with isolating boxes) meeting
@@ -61,7 +61,7 @@ At the moment, `RAGlib` provides two main functions:
6161

6262
For instance, the call
6363

64-
PointsPerComponents([x*y-1], [x^2+y^2-4], []);
64+
RAG[PointsPerComponents]([x*y-1], [x^2+y^2-4], []);
6565

6666
returns
6767

@@ -80,7 +80,7 @@ connected components.
8080

8181
For instance, the call
8282

83-
PointsPerComponents([], [], [(x-1)^2+y^2-1, (x+1)^2+y^2-1-1/2^32]);
83+
RAG[PointsPerComponents]([], [], [(x-1)^2+y^2-1, (x+1)^2+y^2-1-1/2^32]);
8484

8585
returns
8686

install.mm

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Installation script for the RAG package.
2+
# Run from the repository root with:
3+
# maple -q install.mm
4+
5+
homedir:=kernelopts(homedir):
6+
savelibname:=cat(homedir, "/libs/"):
7+
mladirname:=cat(savelibname, "rag.mla"):
8+
ssystem(cat("rm -f ", mladirname)):
9+
libname:=savelibname,libname:
10+
11+
try
12+
with(MSolve):
13+
catch:
14+
printf("Error: failed to load MSolve. Please install the file interface first.\n"):
15+
quit:
16+
end try:
17+
18+
raglib_root:=currentdir():
19+
raglib_src_dir:=cat(raglib_root, "/src"):
20+
kernelopts(includepath=raglib_src_dir):
21+
22+
raglib_src:=cat(raglib_src_dir, "/rag.mm"):
23+
try
24+
read raglib_src:
25+
catch:
26+
printf("Error: failed to load RAGlib sources. Please run the installation script from the repository root.\n"):
27+
quit:
28+
end try:
29+
30+
if not(evalb(whattype(eval(RAG)) = package)) then
31+
printf("Error: failed to load RAG package.\n"):
32+
quit:
33+
end if:
34+
35+
march(`create`, mladirname):
36+
savelib(`RAG`):
37+
printf("Installed RAG package into %s\n", mladirname):

src/rag-main.mm

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
(** This file is part of RAGlib (Real Algebraic Geometry Library).
3+
*
4+
* RAGlib is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* RAGlib is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with RAGlib. If not, see <https://www.gnu.org/licenses/>
16+
*
17+
* Authors:
18+
* Mohab Safey El Din **)
19+
20+
#Exported functions of RAGlib
21+
22+
HasRealSolutions:=proc(eqs, pos, ineqs, opts:={})
23+
local isempty, _l, newopts;
24+
25+
if type(subs(opts, "isempty"), integer) then
26+
isempty:=subs(opts, "isempty");
27+
else
28+
isempty:=0:
29+
end if;
30+
31+
if isempty = 0 then
32+
return SemiAlgebraicSolve(eqs, pos, ineqs, opts union {"isempty"=1});
33+
else
34+
newopts:=map(_l->if lhs(_l)="isempty" then lhs(_l)=1 else _l fi, opts);
35+
return SemiAlgebraicSolve(eqs, pos, ineqs, newopts);
36+
end if;
37+
end proc:
38+
39+
PointsPerComponents:=proc(eqs, pos, ineqs, opts:={})
40+
local isempty, _l, newopts;
41+
42+
if type(subs(opts, "isempty"), integer) then
43+
isempty:=subs(opts, "isempty");
44+
else
45+
isempty:=0:
46+
end if;
47+
48+
if isempty = 0 then
49+
return SemiAlgebraicSolve(eqs, pos, ineqs, opts);
50+
else
51+
newopts:=map(_l->if lhs(_l)="isempty" then lhs(_l)=0 else _l fi, opts);
52+
return SemiAlgebraicSolve(eqs, pos, ineqs, newopts);
53+
end if;
54+
end proc:

0 commit comments

Comments
 (0)