Gordon Royle on Mon, 15 Sep 2025 09:35:32 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Using Pari from within a C program
|
- To: pari-users <pari-users@pari.math.u-bordeaux.fr>
- Subject: Using Pari from within a C program
- From: Gordon Royle <gordon.royle@uwa.edu.au>
- Date: Mon, 15 Sep 2025 07:35:21 +0000
- Accept-language: en-AU, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=uwa.edu.au; dmarc=pass action=none header.from=uwa.edu.au; dkim=pass header.d=uwa.edu.au; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LUQna8YdvrzHD0D+3JIMp62bQtaMrw7OdptMXdmyz6M=; b=aeyjrZJ2pHW8/HIFV1bsf3tGvWWI8jx1vtfoKBuPOCfJBVuYeF9//N1nj0upqpTp3iBosFhoglYF9Sc0npaNUzuHpBozG9bVldae82iTWyr7UN5iiLXuTlgjRDs2jqv345b5ALvjOl5qPxdH6WYVq6N+d6wabj24PJYPtmz/7u1MVaOhEH6b98najI0qfFy+dsNR6quOiVBOEbWeqpcEPzGLek6PpGGdGBYPQZrNST0IU8XyLgXj1nlv4BywUD3WxttB+IWCosw5IX2U9zFGqwiyscx0OuuahNf7TI3TfUd31nRmH6pDCHitvVmeW4HcxVX3DqiqFRDPm+KceTxePw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BvYraj1kL47fur7C7QtawtlHImUNA5h1NsyAX7Hn/fVlyjtPbO/i4+Z2k9DpeojdTEND5y92Uvw1xsJUAyBxGS59EkvbeHDWXK0Q70uFhx4i+Jt42VhRpZnZAZxrl4ikyw5nG+mD9rbzZ8dk3NGOFruWucjQWiWW9cLWNRIOt4F4zufhK2PHH2PrT65h++Y9GFE7ts93zs8Azmkm5qOjBXIyTk4riwpOUWyVsc8qhiOD5Gjyw4y0lLo9yTkl1WR+hq57eQ9bJbs8KUo2s5ZoQMvnac9rYu+n34qxfqWC4CGmqGDt3rtfaFZ/vTmPvJpWldBY2pN8HMGvBff5iqaZkw==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=uwa.edu.au;
- Delivery-date: Mon, 15 Sep 2025 09:35:32 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uwa.edu.au; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LUQna8YdvrzHD0D+3JIMp62bQtaMrw7OdptMXdmyz6M=; b=TqIDYN8W6klAO/L9ptU16iwj75099F0JqCNkfqew2F7pm91IQlqX16htAK2hWZb3f4sZmTe4BkrPbF7hpHXBLdWC70VrpRDoJ8XGEACi0nykL6ANedliKcEQdCMUlW5blpCN8A9VVjPFU5prwTfZK6pRG0bgm9pPtcLq/9Mpu3NHFi9+4R8pQp9YOeoNMUfTYBolphSFU3AtBjeev9K6vZsbLMgClWfZIVVv4IfNg+HH0vI1Qs4BZlb6nc6zFThSravPNFZ56AY1vhFI+c5wHk9RNvX1u6wHBvao8Nu3V7S+wqXLZpFYdJTa3eCxA+0/bWtwLXc8ZHcm2c8moehoiw==
- Thread-index: AQHcJeb2eYeV/83vwUWp6alOeHrhjA==
- Thread-topic: Using Pari from within a C program
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