hermann on Sat, 13 Jul 2024 23:11:16 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

New cgal4gp repo — Make CGAL functionality available for PARI/GP.


I asked on Math Stackexchange for correct term ...
https://math.stackexchange.com/questions/4943645/what-is-the-correct-term-for-maximal-minimal-thickness-of-convex-hull-in-%e2%84%9d%c2%b3

... and learned that what I was interested in is called "width of a points set".
I learned about CGAL (Computational Geometry Algorithms Library) during
my searching and found that GGAL has implementation of that!
https://doc.cgal.org/latest/Polytope_distance_d/classCGAL_1_1Width__3.html#abbdf5bd949aea7e58875226e1f62da51

I have PARI/GP code that I want to be able to use "get_squared_width()":
https://gist.github.com/Hermann-SW/f13b8adf7d7e3094f0b6db0bce29a7b8

That code uses GP "qflllgram()" which seems not available in CGAL.

Instead of writing libpari C++ code bringing both together,
which I did in the past:
https://github.com/Hermann-SW/RSA_numbers_factored/blob/main/c%2B%2B/sqrtm1.smallest_known_1million_digit_prime.cc

this time I wanted to bring CGAL functionality to GP.

In section "5.8.4 Integration with gp as a shared module." that is described:
https://pari.math.u-bordeaux.fr/pub/pari/manuals/2.15.5/libpari.pdf#page=79

After partly working code from scratch, I found "Olinux-x86_64/Makefile.examples".
That installs examples under "/usr/local/share/pari/examples", and
just doing "make" there compiles the extgcd demo,

I started with that code, eliminated stuff I did not need, changed to use g++
instead of gcc because of CGAL, and have vertical prototype now:
https://github.com/Hermann-SW/cgal4gp

So nice, I will provide more functionality, but it works already:

$ make
g++ -O3 -ffp-contract=off -fno-strict-aliasing -fPIC -Wall -pedantic -Wextra -Wno-psabi -c -o cgal4gp.o cgal4gp.cpp /usr/bin/g++ -o libcgal4gp.so -shared -Wl,-shared cgal4gp.o -lc -lm -lgmp
gp -q < simple.gp
get_squared_width([[1, 0, 0], [2, -1, 0], [2, 0, -1], [3, 0, 0], [2, 1, 0], [2, 0, 1]])
67108864/50331648
4/3
$

It took a while until I learned from doc that I had to prefix "code" with "v" for
void function:

$ cat cgal4gp.gp
install("get_squared_width", "vG&&", , "./libcgal4gp.so");
$


I was surprised that list search showed only 2 matches for cgal, this will be the third.

Regards,

Hermann.