QiPy

A Python library to work with elements, ideals, ideal classes and class groups from quadratic integer rings.


Keywords
quadratic, integers, ideal, class, group
License
MIT
Install
pip install QiPy==1.0.5

Documentation

QiPy

QiPy is a Python library to work with quadratic integers. Well-known examples are Gaussian integers and Eisenstein integers. Besides, QiPy implements ideals, ideal classes and class groups of quadratic integer rings.

This library has been exhaustively tested with unit tests and property testing.

A complete documentation of QiPy, including examples of all its funcionalities, can be found in the GitHub Page of the repository.

Installation

QiPy is written in Python 3 and uses the Python library SymPy. Therefore, Python 3 and SymPy must be installed in your computer.

The easiest way to install QiPy is with pip :

pip3 install qipy

Examples of usage

Computing frac in Zi:

>>> Zi = QuadraticIntegerRing(-1)
>>> Zi("1 + I") / Zi("1 - I")
I

Factoring 2 in Zi:

>>> Zi = QuadraticIntegerRing(-1)
>>> Zi(2).factor()
[1 + I, 1 - I]

Testing whether the ideal twogen in 5 is principal:

>>> O = QuadraticIntegerRing(-5)
>>> Ideal(O(3), O("1 + sqrt(-5)")).is_principal()
False

Factoring the ideal 2 in Zi:

>>> Zi = QuadraticIntegerRing(-1)
>>> Ideal(Zi(2)).factor()
[<1 + I,2*I>, <1 + I,2*I>]

Computing the order of the ideal class with representative twogen in 5:

>>> O = QuadraticIntegerRing(-5)
>>> a = IdealClass(Ideal(O(3), O("1 + sqrt(-5)")))
>>> a.order
2

Computing the class number of 5:

>>> G = ClassGroup(-5)
>>> G.class_number
2