Python接口,用于数论库PARI/GP
项目描述
Python接口,用于数论库PARI/GP。
安装
从发行版软件包(GNU/Linux,conda-forge)
您的包管理器可能提供了该软件包,请参阅https://repology.org/project/python:cypari2/versions或https://doc.sagemath.org/html/en/reference/spkg/cypari以获取安装说明。
从PyPI的预构建wheel
要求
Python >= 3.9
pip
通过Python包索引(PyPI)安装cypari2
$ pip install cypari2 [--user]
(可选选项–user允许为单个用户安装cypari2,并避免使用管理员权限的pip)。
使用pip从源安装
要求
PARI/GP >= 2.9.4(头文件和库);有关在发行版(GNU/Linux、conda-forge、Homebrew、FreeBSD)中的可用性,请参阅https://doc.sagemath.org/html/en/reference/spkg/pari#spkg-pari,或从源代码安装。
Python >= 3.9
pip
cysignals >= 1.11.3
Cython >= 3.0
通过Python包索引(PyPI)安装cypari2
$ pip install --no-binary cypari2 cypari2 [--user]
(可选选项–user允许为单个用户安装cypari2,并避免使用管理员权限的pip)。
pip使用构建隔离构建包。包的所有Python构建依赖项,在pyproject.toml中声明,都将在临时虚拟环境中自动安装。
如果您想尝试开发版本,请使用
$ pip install git+https://github.com/sagemath/cypari2.git [--user]
使用方法
界面尽可能接近PARI/GP。以下在GP中的计算
? zeta(2) %1 = 1.6449340668482264364724151666460251892 ? p = x^3 + x^2 + x - 1; ? modulus = t^3 + t^2 + t - 1; ? fq = factorff(p, 3, modulus); ? centerlift(lift(fq)) %5 = [ x - t 1] [x + (t^2 + t - 1) 1] [ x + (-t^2 - 1) 1]
转换为
>>> import cypari2 >>> pari = cypari2.Pari() >>> pari(2).zeta() 1.64493406684823 >>> p = pari("x^3 + x^2 + x - 1") >>> modulus = pari("t^3 + t^2 + t - 1") >>> fq = p.factorff(3, modulus) >>> fq.lift().centerlift() [x - t, 1; x + (t^2 + t - 1), 1; x + (-t^2 - 1), 1]
上面的对象pari是接口对象,充当构造函数。它可以与基本Python对象(如整数或浮点数)一起调用。当使用字符串作为最后一个示例时,相应的字符串将被解释为在GP外壳中执行。
除了类型为Pari的接口对象pari之外,您获取的任何对象都是类型为Gen的对象(它是libpari中的GEN类型的包装器)。然后,所有PARI/GP函数都以它们原始的名称作为方法(如上所述的zeta、factorff、lift或centerlift)可用。
或者,可以通过pari作为方法访问pari函数。可以通过以下方式执行相同的计算
>>> import cypari2 >>> pari = cypari2.Pari() >>> pari.zeta(2) 1.64493406684823 >>> p = pari("x^3 + x^2 + x - 1") >>> modulus = pari("t^3 + t^2 + t - 1") >>> fq = pari.factorff(p, 3, modulus) >>> pari.centerlift(pari.lift(fq)) [x - t, 1; x + (t^2 + t - 1), 1; x + (-t^2 - 1), 1]
cypari2的完整文档可在http://cypari2.readthedocs.io找到,PARI/GP文档在http://pari.math.u-bordeaux.fr/doc.html。
贡献
CyPari 2 由 SageMath 社区维护。
在https://github.com/sagemath/cypari2上提出问题或提交拉取请求,并加入https://groups.google.com/group/sage-devel进行讨论。
项目详细信息
散列 对于 cypari2-2.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | 3f24b1b647c5e1be15d4cf7876af727b1e77c53b12fa1bf50624c3e9ed25a349 |
|
MD5 | 202529ed927c97d7e4826ccb0973d97e |
|
BLAKE2b-256 | 38188b07c1284e3af5f3d99952f9791bafac8767f7792113d6e87fbf82034aa1 |
散列 对于 cypari2-2.2.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | d2cabbe6220eee9f23511670888fe6925376c1656871fb242d954508f8cc6223 |
|
MD5 | 1544820b25ba6265977efa258724bb5a |
|
BLAKE2b-256 | 71b14f14dde91d2c42ec955d74347977ffdb1cd7ea52b8653d3a6150f5aab9a1 |
散列 对于 cypari2-2.2.0-cp312-cp312-macosx_11_0_arm64.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | 7525e3cdff6228dbfea8ef84df6a4ce969d7abfdc6c79801f50f20c18df29168 |
|
MD5 | b41fd26404459b6d7246376e6eb8d198 |
|
BLAKE2b-256 | 90024f02ee457dce118e19d63f88ecba5adc144fb18b9402993d7f1fac218b6e |
散列 对于 cypari2-2.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | f74a0e133056ca4975b4628dad43bc4002022a56ef29e5fc3a106c06cafe4606 |
|
MD5 | 4b86fdf86d713557b267d9d012c7398f |
|
BLAKE2b-256 | 8056d3df35f78504515b467324b1d0e4c63036d4258774b8def3d33af276a355 |
散列 对于 cypari2-2.2.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | 464fc17f3db972a4110dd190cc39630cc6ac6592bec24e53e93e334eb30ca735 |
|
MD5 | e2eeb25857f69ecc85455648b20073b0 |
|
BLAKE2b-256 | 9e22b18fefb509098d190b1a820d0c5722edb7de84a24ec61ab6ec5f62a89f2d |
散列 对于 cypari2-2.2.0-cp311-cp311-macosx_11_0_arm64.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | 27a8a1af1e7aea0c6c9537913e6a95d31a03f030da697ba4eb290ec2cd35ac61 |
|
MD5 | 96c253899cff33891dfd566b7192ff66 |
|
BLAKE2b-256 | 3a0adf65d02c94a3509c5d300ec63ebe23ec1a573abc10c29a2ce7dc93e11055 |
散列 对于 cypari2-2.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | 55d340d0436b966993bfdee189bb6f9392f6ca84fe67f766b09582a9f17eac0e |
|
MD5 | 6fa29ad7dadd4d5258cd59badea97c1e |
|
BLAKE2b-256 | 64807d33ecaa5e8e939b13306b4fad7be6671c82ab34fd2b789dc3f6be86ba7d |
散列 对于 cypari2-2.2.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | 656ddfb50395c9bc266e62b530ddb7eb30ebd8f477a7267e1b20c2e39c902bd2 |
|
MD5 | 881cb216235a5247898ce209aca8c20a |
|
BLAKE2b-256 | 8e400e17b73364436c308d6126b14d344833a5fcdccfeb5cb862375a25b76ba6 |
散列 对于 cypari2-2.2.0-cp310-cp310-macosx_11_0_arm64.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | e0e349c6ac08c2e515fc3179431f874c667495aa25d5c0097157b44b6712e50c |
|
MD5 | 923cd6274db1aacc26ee43c63ec48dc2 |
|
BLAKE2b-256 | eff011d998de6610daf0d8db05d5145b0218d93c861395d84a43a35c1fe8a287 |
散列 对于 cypari2-2.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | c88db3231b21f3907278f801667bce45b6a539ac9f4104ddf563775114d7962e |
|
MD5 | ae985ff465dc75f9323a362e2faeda4d |
|
BLAKE2b-256 | 0939acc54656947b2a47265615f5f9e8454cc04dceca5488ac872c6a133076bb |
散列 对于 cypari2-2.2.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | ec591ca129f8d70b87399e5cff10f9536271786bc4378801e0cc2d630245fc46 |
|
MD5 | 7890eb6311538e600bfe84173d21c439 |
|
BLAKE2b-256 | 6ddf29f3436d351a49c52bf6c2dc8954f34260e35d741c8747c07ba11182fd17 |
哈希值 用于 cypari2-2.2.0-cp39-cp39-macosx_11_0_arm64.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | fa29690934e1b799ba2940c5ed60ceeabe19a31f38b8f5cfb75d1170bed185e3 |
|
MD5 | f24b53b5b7101ac6a52d2625cf66a66a |
|
BLAKE2b-256 | d9be34d2f05ea8f78261c4f725f84a26a4f168287938bce8cf4e8a02ba81ee70 |