libppl_c(3)

πŸ’– libppl_c β€” the C interface of the Parma Polyhedra Library πŸ’–

okay bestie, so this is the libppl_c manual page from the PPL 1.2 era, and it's literally just the cutest lil' tour of how to use the Parma Polyhedra Library (PPL) from your C code on Unix-like systems. it's the overview page, not the whole lore β€” but it's giving ✨ essential ✨ so let's go.


🌸 SYNOPSIS 🌸

#include <ppl_c.h>

cc file.c -lppl

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so first things first: this is a short overview on how to use the Parma Polyhedra Library (aka PPL) in your C programs on Unix-like operating systems. that's the whole assignment, bestie. πŸ’…

heads up tho β€” the PPL also has interfaces for C++, Java, OCaml, and a number of Prolog systems, so if you're here for those, you're in the wrong group chat, go look elsewhere for their docs. πŸ™ˆ

and like, super important: this document does not describe the library functionality, its classes, or its methods and functions. for that kind of info you need The Parma Polyhedra Library User's Manual (version 1.2) and The Parma Polyhedra Library C Language Interface User's Manual (version 1.2). no cap, that's where the real content lives. πŸ“š


πŸŽ€ INCLUDING THE HEADER FILE πŸŽ€

the C interface of the PPL has only one header file and its name is ppl_c.h. so your program should contain a directive of the form:

#include <ppl_c.h>

obviously you have to make sure you installed the PPL somewhere the compiler can actually find it β€” either it finds it by itself, or you help it out with a suitable -Idir command line option. (peep the file INSTALL for info on how to configure the library so it gets installed wherever you want it. iconic behavior.) 🫢


✨ INITIALIZING AND FINALIZING THE LIBRARY ✨

to initialize the Parma Polyhedra Library you must call this function:

int ppl_initialize(void)

and you gotta do it before using any of its functionalities. like, non-negotiable. πŸ”₯

it's also a good norm to call this one:

int ppl_finalize(void)

when you're done with the library. clean up after yourself, main character energy. πŸ’…


🌈 USING THE LIBRARY 🌈

keeping in mind that there is no substitute for a careful reading of The Parma Polyhedra Library User's Manual (version 1.2) and The Parma Polyhedra Library C Language Interface User's Manual (version 1.2)… 😭

…you can find examples of use in these directories of the source distribution:

  • interfaces/C/tests
  • demos/ppl_lpsol

πŸ‘‘ LINKING WITH THE LIBRARY πŸ‘‘

linking with the C interface of the PPL is best done using the C compiler itself. usually, specifying the -lppl_c command line option is enough β€” periodt. πŸ’…

in fact, if you use a shared version of the library, this automatically records the dependency from the PPL core and the GMP libraries, something that the linker ought to deal with gracefully. 🌸

otherwise (if it's not shared, bestie), you'll have to add this to the command line:

-lppl -lgmpxx -lgmp

things get more complex if you installed the PPL into some nonstandard place. in that case you'll have to use the -Ldir option and, if you use a shared version of the library, possibly take further steps. see the documentation of your system for more info on this β€” and for GNU/Linux users, the Program Library HOWTO is especially valuable. πŸ“–


πŸ’œ RETURN VALUES πŸ’œ

all the PPL C interface functions return an int. a negative value means that an error occurred. 😭

see The Parma Polyhedra Library C Language Interface User's Manual (version 1.2) for the error codes.


🧚 IMPLEMENTING MEMORY-GUARDED COMPUTATIONS 🧚

one of the interesting features of the Parma Polyhedra Library is the possibility to implement memory-guarded computations. the idea is:

  • you can limit the amount of virtual memory available to the process,
  • launch a PPL computation,
  • and be ready to be returned a PPL_ERROR_OUT_OF_MEMORY error code.

you can then take the appropriate corrective measures (e.g., simplify the polyhedra and/or select less precise though less complex algorithms), and restart the computation. πŸ”

in order to do that, you should define alternative memory allocation functions for GMP that throw std::bad_alloc upon memory exhaustion. see libppl(3) for instructions on how to do that.


πŸ“ USING NATIVE FLOATING POINT NUMBERS πŸ“

at initialization time, the Parma Polyhedra Library sets the FPU rounding mode in a way that allows its floating-point-based computations to be conservative (i.e., possibly approximated but correct) and reasonably efficient. slay. ✨

in case your application itself uses native floating point numbers and relies on a particular rounding mode β€” and if you are in doubt, assume that it does rely on round-to-nearest being in effect β€” you should use this function:

int ppl_restore_pre_PPL_rounding()

after the PPL initialization and before using native floating point numbers in the application. 🫢

if your application does not use any floating-point-based PPL abstraction, no further measure should be taken.

otherwise, it is imperative to call this function:

int ppl_set_rounding_for_PPL()

before invoking any PPL interface related to such abstractions. > imperative, bestie. like, do not skip this one. πŸ’€


πŸ”₯ SEE ALSO πŸ”₯


πŸ’– AVAILABILITY πŸ’–

the latest version of the Parma Polyhedra Library and all the documentation is available at http://bugseng.com/products/ppl/ . πŸŽ€


⭐ AUTHOR ⭐

see the file CREDITS in the source distribution, or use this command for a list of contributors:

ppl-config --credits

πŸ™ˆ REPORTING BUGS πŸ™ˆ

report bugs to <ppl-devel@cs.unipr.it>.


Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it> Copyright
(C) 2010-2016 BUGSENG srl (http://bugseng.com)

this is free software; see the file COPYING in the source distribution or use the command ppl-config --copying to obtain the copying conditions.

There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. πŸ’€ like fr fr, none. zero. nada.

okay that's the whole page bestie, you ate πŸ’…βœ¨ β€” and just so you know where this lore came from: it's the libppl_c overview page, version PPL 1.2, dated February 2016. mwah, go compile something iconic πŸ¦‹πŸ’–