A general purpose Python math module
Project description
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
Built Distributions
Hashes for libpymath-0.3.6-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58ac0dbc26233bfc9b928523ddfd8460c4027c7123880e2a2912240da2e1502e |
|
MD5 | 7a1a73e3160caf8f04dc0fa8b6530e84 |
|
BLAKE2b-256 | 1b34882ff34f378d2f81888e12e57c4626afa55967337b081cfad59361540f5c |
Hashes for libpymath-0.3.6-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ec9f4114d7305ab401d8771fe3c271543b453c4e9ca73e3bfb938f114b48213 |
|
MD5 | 7ffc5c6a8acc73f67b43cf45e881a5b5 |
|
BLAKE2b-256 | fab70f4a44b9a7013432795542093db205cd1bb0c7c9212b17f43d51e4fa2e71 |
Hashes for libpymath-0.3.6-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05c63a096f4a0a687da1f9cfb5133bda7be4acdfef131db81f5607166fd6f067 |
|
MD5 | f7c931400e06ef688110e173eeb0b551 |
|
BLAKE2b-256 | 0a5697780882ea32779e79ef3fc7827a6454547524b761d5ab97c9c8556138cc |
Hashes for libpymath-0.3.6-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28ecac99f15dc5f700c040052f09949fc498fbe04b3056f7dcb7377bbeff6dcb |
|
MD5 | d95611df9889bcb42e2594d5c9d71e86 |
|
BLAKE2b-256 | f02d6601182e4854f040c9a539d1926c6c15bdbfecc86509223093cc82612286 |
Hashes for libpymath-0.3.6-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a8ea7e130b50370493025620cdeea477ae6423dc030912adb1f30b3c6eae366 |
|
MD5 | 863d5f3ef143d569d751e9b8fe29aed6 |
|
BLAKE2b-256 | 35b5527641ad5f3e51bcd50b75906def9fde93362a00eaea46dc480392f50d91 |
Hashes for libpymath-0.3.6-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9caaf2545795fd518bd84eb4845373bd500eef69c52bc120fcb3593eb1357b6 |
|
MD5 | 870bd913627fd5a39d1869e5194bce04 |
|
BLAKE2b-256 | 4f3d76730d341837228bd6243d29a7bb40d22c6e57cc6cdc4ac863be9f309a69 |
Hashes for libpymath-0.3.6-cp37-cp37m-macosx_10_9_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f025834e2bfa379d88bb5b1599fa64f4e452201b005c85743252f6cccee18ba |
|
MD5 | 85febd5742520fa1308af5f728e8d6df |
|
BLAKE2b-256 | af26704997e2b1a2133043485bd7f85db4f1815a219d11ca053c0fa6c4e4bad5 |
Hashes for libpymath-0.3.6-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a071284975b4d6deff854b3ddd58946e1f27a7d545bc191a32750dc1783948d |
|
MD5 | f21f35b458d40d6cc574deec0a0b91a9 |
|
BLAKE2b-256 | d214d19573899663ddd2e1adee88b60fa8014e3c2c8ef8ba03ed853f451a6586 |
Hashes for libpymath-0.3.6-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ec7c8ecea6935708e16e6533b0855fcc02862d27f582e6d367c375f1946cace |
|
MD5 | 476e904a17c223d6ca1cd4298226ad45 |
|
BLAKE2b-256 | d5cd865e3fa5c0852471079d8beae75e67970fc62247019e1880438d15ae4b2c |
Hashes for libpymath-0.3.6-cp36-cp36m-macosx_10_9_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f94825a909a14b83b3ea5a0f23f742c0a6ec34eabd0b4edf6339e9d9c970dfe |
|
MD5 | e841dea1fadd5461692a23ca9b9ebc17 |
|
BLAKE2b-256 | 1558c9eec0758fdf969ac8b507bce5767c6decea9266af160105514b5afac24f |
Hashes for libpymath-0.3.6-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f2501458d8c3b24e549f37c30ca8346eea9d5f2865f6a4e2cd7571e55c797dd |
|
MD5 | 67c89cbc05ea8046b340bc381ed0e6d5 |
|
BLAKE2b-256 | 15c6ccdd8a1d8da2331462d62578f8cd16dd4de5d885d763df260ca37393f37f |
Hashes for libpymath-0.3.6-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bee6344e207c4d5412da3592ce0fb2b38ba70c8de0068f86501a1ef73bb90cee |
|
MD5 | 3a8005a05c83cec1c958350ef33d30b1 |
|
BLAKE2b-256 | 396371e54ca8082f813db6c7f277ad3d3fe859ae606fc4acd3aef4ae2e3440b1 |
Hashes for libpymath-0.3.6-cp35-cp35m-macosx_10_9_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17f350d6adcfb69259dc3513b395dbfe714f818f160e6ac371fde698c1e4d212 |
|
MD5 | 9a5f7203f66d6d59ba26b8dca47d2ed3 |
|
BLAKE2b-256 | 43001e884a14b62c12241e3c24a289ca4a5a4ac2312536a682616f95c2019b21 |