Bill Allombert on Mon, 15 Sep 2025 14:03:56 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Using Pari from within a C program |
On Mon, Sep 15, 2025 at 07:35:21AM +0000, Gordon Royle 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. What are the coefficients of your matrices ? C long ? > 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 Yes, but you could stop as soon as you find a strictly negative eigenvalue value, you do need to finish computing the signature. Unless you have high probability that the matrix does not have strictly negative eigenvalue, you can start by doing quick checks. For example check that the trace is positive. > So logically it all seems ok You will need to initialize PARI/GP somewhere in your code. Cheers, Bill.