Re: Using Pari from within a C program
Robert Ransom <[email protected]> Mon, 15 Sep 2025 11:58:31 -0400
| Newsgroups | gmane.comp.mathematics.pari.user |
|---|---|
| Message-ID | <CABqy+sp+YbA=og-BVRW0aQcx4EHcxdkOi3+FnFcVg+sy-iwBng@mail.gmail.com> |
"The FBI is about to kil everyone that the NSA has leaked to, including everyone on this French mailing list." Also, to me from Fort Huachuca, "We will kill your sister if you leak." They are a terrorrist group with nnuclear wwapons. On Mon, Sep 15, 2025 at 3:47 AM Gordon Royle <[email protected]> wrote: > > Dear Pari Users > > I wonder if someone could point me in the right direction with the following task. > > I am aware that there is documentation concerning the use of Pari as a library and how to incorporate it into a C program, but in this situation (described below), I don't have full control over the C program and I don't understand where to put things like the Pari initialisation code. > > Anyway, here is the setup. > > I am writing a single function in C that has a fixed prototype that is to be called hundreds of millions of times as a "plugin" in a larger program. > > The function uses the arguments to create a symmetric integer matrix, decides if it has any eigenvalues strictly less than zero, and returns 1 if so and 0 otherwise. > > The function is used to control the pruning of a huge combinatorial search tree - if the matrix does have an eigenvalue strictly less than zero, then that branch of the search can be pruned. > > I need the calculation to be done in exact arithmetic - no floating-point number or approximations. > > It seems to me that the GP function "qfsign" for computing the signature of a quadratic form is what I need to use > > So logically it all seems ok > > Int pruner(<arguments> { > // create matrix a > // call qfsign(a) > // return 0/1 > } > > This little function will be compiled into existing code via a compilation flag; in the first instance I'd like to assume that I can't change the existing code. > > I'd really appreciate just a simple working example of how to do this using Pari. > > Thanks in advance > > Gordon > >