Skip to main content

A quadint class, for using quadratic integers.

Project description

This library provides a QuadInt class for dealing with Quadratic integers.

Additionally, a complexint class is provided by default where D == -1 obviously. This class acts just like Python's built-in complex except it is backed by Python integers instead of doubles. This allows for infinite precision.

Examples

from quadint import complexint

a = complexint(1, 2)
b = complexint(3, 6)

c = a * b
print(c)  # Outputs "-9+12j"

print(type(c.real))  # Outputs "int"
from quadint import make_quadint

Q2 = make_quadint(-2)

a = Q2(1, 2)
b = Q2(3, 6)

c = a * b
print(c)  # Outputs "(-21+12*sqrt(-2))"

Disclaimer

This is intended for use with discrete mathematics, and ideally will be limited to the operations: add, sub, mul, and pow.

Trying to divide using this class, or using floats with this class, will (probably) result in integer conversion cutoff.

As an example of this problem, note the equivalences below:

from quadint import complexint

a = complexint(3, 6)

print(a / 3)  # Outputs "(1+2j)
print(a / 3.5)  # Outputs "(1+2j)"

print(a + 1)  # Outputs "(4+6j)"
print(a + 1.5)  # Outputs "(4+6j)"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quadint-0.0.1.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quadint-0.0.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file quadint-0.0.1.tar.gz.

File metadata

  • Download URL: quadint-0.0.1.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for quadint-0.0.1.tar.gz
Algorithm Hash digest
SHA256 57a4e43e63852497b00e17764335e239fc8e22a136b0ee195cbbeecb375524ec
MD5 30b55a26573555c1d4a94b165da6369e
BLAKE2b-256 c86ad3550387285eff1b38702dd08d02f73251133926e4d8177947efbca2bbcc

See more details on using hashes here.

File details

Details for the file quadint-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: quadint-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for quadint-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cb4e78e15e2f43e8ac447c642d82bab2297ee203980a7613deff5089be1178f5
MD5 ec522f2fd3715c27a8ea9ca6f808d2b3
BLAKE2b-256 f495da5dca17cfe60de0d7c2761ae75943fe47683c1c148d0a700e46f96e63b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page