File: README.rst

package info (click to toggle)
cypari2 2.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 908 kB
  • sloc: python: 972; makefile: 34; ansic: 5
file content (135 lines) | stat: -rw-r--r-- 3,612 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
CyPari 2
========

.. image:: https://travis-ci.org/sagemath/cypari2.svg?branch=master
    :target: https://travis-ci.org/sagemath/cypari2
.. image:: https://readthedocs.org/projects/cypari2/badge/?version=latest
    :target: https://cypari2.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status

A Python interface to the number theory library `PARI/GP <http://pari.math.u-bordeaux.fr/>`_.

This library supports both Python 2 and Python 3.

Installation
------------

GNU/Linux
^^^^^^^^^

A package `python-cypari2` or `python2-cypari2` or `python3-cypari2` might be
available in your package manager.

Using pip
^^^^^^^^^

Requirements:

- PARI/GP >= 2.9.4 (header files and library)
- Python 2.7 or Python >= 3.4
- pip
- `cysignals <https://pypi.python.org/pypi/cysignals/>`_ >= 1.7
- Cython >= 0.28

Install cypari2 via the Python Package Index (PyPI) via

::

    $ pip install cypari2 [--user]

(the optional option *--user* allows to install cypari2 for a single user
and avoids using pip with administrator rights). Depending on your operating
system the pip command might also be called pip2 or pip3.

If you want to try the development version use

::

    $ pip install git+https://github.com/sagemath/cypari2.git [--user]

If you have an error saying libpari-gmp*.so* is missing and have all requirements
already installed, try to reinstall cysignals and cypari2

::

    $ pip install cysignals --upgrade [--user]
    $ pip install cypari2 --upgrade [--user]

Other
^^^^^

Any other way to install cypari2 is not supported. In particular, ``python
setup.py install`` will produce an error.

Usage
-----

The interface as been kept as close as possible from PARI/GP. The following
computation in 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]

translates into

::

    >>> 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]

The object **pari** above is the object for the interface and acts as a
constructor. It can be called with basic Python objects like integer
or floating point. When called with a string as in the last example
the corresponding string is interpreted as if it was executed in a GP shell.

Beyond the interface object **pari** of type **Pari**, any object you get a
handle on is of type **Gen** (that is a wrapper around the **GEN** type from
libpari). All PARI/GP functions are then available in their original names as
*methods* like **zeta**, **factorff**, **lift** or **centerlift** above.

Alternatively, the pari functions are accessible as methods of **pari**. The
same computations be done via

::

    >>> 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]

The complete documentation of cypari2 is available at http://cypari2.readthedocs.io and
the PARI/GP documentation at http://pari.math.u-bordeaux.fr/doc.html

Contributing
------------

Submit pull request or get in touch with the SageMath developers.