A simple Python library for matrix multiplication
Project description
ALUMatrixMath
A simple Python library for matrix multiplication with proper validation.
Installation
pip install alumathgroup3
QuickStart
from alumathgroup3 import Matrix, matrix_multiply
# Create matrices
A = Matrix([[1, 2, 3], [4, 5, 6]]) # 2×3 matrix
B = Matrix([[7, 8], [9, 10], [11, 12]]) # 3×2 matrix
# Multiply matrices
result = A * B
print(result)
print(f"Result shape: {result.shape()}") # (2, 2)
Features
✅ Matrix multiplication with dimension validation ✅ Clear error messages for incompatible matrices ✅ Clean display formatting ✅ Support for different matrix dimensions
More example using alumath
from alumath import Matrix, matrix_multiply
# Example 1: Compatible matrices
print("Example 1: 2x3 × 3x2 matrices")
m1 = Matrix([[1, 2, 3], [4, 5, 6]])
m2 = Matrix([[7, 8], [9, 10], [11, 12]])
print(f"Matrix A {m1.shape()}:")
print(m1)
print(f"\nMatrix B {m2.shape()}:")
print(m2)
result = m1 * m2
print(f"\nA × B = {result.shape()}:")
print(result)
print()
# Example 2: Different dimensions
print("Example 2: 3x2 × 2x4 matrices")
m3 = Matrix([[1, 2], [3, 4], [5, 6]])
m4 = Matrix([[1, 0, 1, 2], [2, 1, 0, 1]])
print(f"Matrix C {m3.shape()}:")
print(m3)
print(f"\nMatrix D {m4.shape()}:")
print(m4)
result2 = matrix_multiply(m3, m4)
print(f"\nC × D = {result2.shape()}:")
print(result2)
print()
# Example 3: Error case
print("Example 3: Incompatible matrices (will show error)")
try:
m5 = Matrix([[1, 2]]) # 1x2
m6 = Matrix([[1], [2], [3]]) # 3x1
print(f"Trying to multiply {m5.shape()} × {m6.shape()}")
result3 = m5 * m6
except ValueError as e:
print(f"Error: {e}")
License
MIT License
LICENSE
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file alumathgroup3-1.0.0.tar.gz.
File metadata
- Download URL: alumathgroup3-1.0.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bcadc08dd4b70efa2af9a05cd558e69f059e15b8834bc045691cea571957c3b
|
|
| MD5 |
f4ecbdba90224db38b6a2e2b9d35961d
|
|
| BLAKE2b-256 |
3cb90584df91c3ef38adbd5e47c9d0e1ba139bdd1ce870f0b9da0d74e82cc03d
|
File details
Details for the file alumathgroup3-1.0.0-py3-none-any.whl.
File metadata
- Download URL: alumathgroup3-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bea477bd6fea453d7e51e4bba55b5d9a94605f81effe97b8e30c1aaa79aacde
|
|
| MD5 |
e3843d590f72c55013fe770470839e6f
|
|
| BLAKE2b-256 |
8d537756637c50ccd3efd8132dbb4cd380d090334efe814ebab51ac7f02b17f7
|