Skip to main content

A general purpose Python math module

Project description

Build Status Documentation Status PyPI version fury.io PyPI license PyPI pyversions Downloads per month

LibPyMath

A fast, general purpose math library for Python


Install

Run pip install libpymath to dowload and install libpymath for your system. There are also wheels provided for many of the latest Python versions on Windows, Mac OS* and Linux thanks to the cibuildwheel project.


Features and usage

Matrix math

Easily create, manipulate and perform calculations with dense matrices. The matrices themselves are stored and manipulated with optimised C code, resulting in faster operations and more efficient calculations. To further increase the speed of the calculations, when libpymath imported into a project for the first time, it runs some tests on the CPU to find the optimal number of threads to use for the matrix calculations.

The matrix library is currently in its early stages and only supports elementwise addition, subtraction, division and multiplication, as well as the matrix transpose function and some ease of use functions, such as the ability to format and print a matrix, alligning the decimal points (if present) and providing brackets in the relevant places.

For example, the following creates a new matrix from a 2d list of data

# Import the Matrix object from the matrix library
from libpymath.matrix import Matrix

# Create the data
matrixData = [[1, 2, 3],
              [4, 5, 6],
              [7, 8, 9]]

# Produce a new Matrix with the data
mat = Matrix(data=matrixData)

# Print the matrix
print(mat)

>>> [[1.0, 2.0, 3.0]
     [4.0, 5.0, 6.0]
     [7.0, 8.0, 9.0]]

Here is another example to show the formating abilities of libpymath's matrix type. The decimal points, commas and brackets are all alined on a per-row basis, saving space and producing a nicer result.

# Create the data
matrixData = [[1, 2, 3.14159],
              [4, 5000, 6],
              [7, 8, 9]]

# Produce a new Matrix with the data
mat = Matrix(data=matrixData)

# Print the matrix
print(mat)

>>> [[1.0,    2.0, 3.14159]
     [4.0, 5000.0, 6.0    ]
     [7.0,    8.0, 9.0    ]]

The example below shows what happens when printing a large matrix, as the entire thing could not fit on the screen -- libpymath shows only the corners, missing out the middle section of the matrix on both the x and y axis, allowing large matrices to be printed quickly and using a small amount of space.

# Create the data for a 1000x1000 matrix
rows = 1000
cols = 1000
matrixData = [[j + i * cols for j in range(rows)] for i in range(cols)]

# Produce a new Matrix with the data
mat = Matrix(data=matrixData)

# Print the matrix
print(mat)

>>> [[     0.0,      1.0,      2.0  ***     997.0,    998.0,    999.0]
     [  1000.0,   1001.0,   1002.0  ***    1997.0,   1998.0,   1999.0]
     [  2000.0,   2001.0,   2002.0  ***    2997.0,   2998.0,   2999.0]
           ***       ***       ***            ***       ***       ***  
     [997000.0, 997001.0, 997002.0  ***  997997.0, 997998.0, 997999.0]
     [998000.0, 998001.0, 998002.0  ***  998997.0, 998998.0, 998999.0]
     [999000.0, 999001.0, 999002.0  ***  999997.0, 999998.0, 999999.0]]

* Due to Clang on Mac OS the wheels do not support OpenMP, meaning some matrix operations may be slower than on other operating systems.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

libpymath-0.3.9.tar.gz (119.0 kB view details)

Uploaded Source

Built Distribution

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

libpymath-0.3.9-cp38-cp38-win_amd64.whl (37.4 kB view details)

Uploaded CPython 3.8Windows x86-64

File details

Details for the file libpymath-0.3.9.tar.gz.

File metadata

  • Download URL: libpymath-0.3.9.tar.gz
  • Upload date:
  • Size: 119.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for libpymath-0.3.9.tar.gz
Algorithm Hash digest
SHA256 3f44970a4cc0db9f3e2c926a80be528599dc4fd5cae8aebe646e5091bfca18c3
MD5 379ee1bd17109280a3dfc080e31ebc24
BLAKE2b-256 7f2f07959edc87257326bfaadf0e567203deb2e775ee62e543506a92aa036e97

See more details on using hashes here.

File details

Details for the file libpymath-0.3.9-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: libpymath-0.3.9-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for libpymath-0.3.9-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 dc3171662a15746dd4ec1fa6222c45306a4b67a8c6ae18df2e4b8313f53f276c
MD5 d00b3f780a0672fe8453b740ac0f46c0
BLAKE2b-256 e73133d806baaf043b3af60cc9a0a0557da84f177968ed480bcbfcbea3994b62

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