LUMIN
Library for Unified Matrix INfrastructure - A high-performance matrix operations library with multiple backend support (CPU, OpenMP, CUDA, MPI).
Features
- 🚀 High Performance: Optimized C++ implementation with multiple backend support
- 🔧 Multiple Backends: CPU, OpenMP, CUDA, and MPI backends
- 🐍 Python Bindings: Easy-to-use Python API via pybind11
- 🔄 NumPy Integration: Seamless conversion to/from NumPy arrays
- ⚡ Flexible: Choose the best backend for your hardware and workload
Installation
pip install lumin-matrix
Requirements
- Python 3.6+
- NumPy
- C++17 compatible compiler (for building from source)
Optional dependencies (for specific backends):
- OpenMP (for parallel CPU operations)
- CUDA Toolkit (for GPU acceleration)
- MPI (for distributed computing)
Quick Start
import lumin
import numpy as np
# Create matrices
A = lumin.Matrix(3, 3)
B = lumin.Matrix(3, 3)
# Fill with values
for i in range(3):
for j in range(3):
A[i, j] = i * 3 + j + 1
B[i, j] = (i * 3 + j + 1) * 2
# Matrix operations
C = A + B # Addition
D = A * B # Matrix multiplication
E = A.transpose() # Transpose
dot = A.dot(B) # Dot product
# Scalar operations
F = A * 2.5 # Scalar multiplication
G = 3.0 * A # Right-side scalar multiplication
# NumPy integration
arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=np.float64)
M = lumin.Matrix(arr) # Convert NumPy array to LUMIN Matrix
result = M.to_numpy() # Convert back to NumPy
# Random matrix
R = lumin.Matrix.random_int(5, 5, max_value=100)
# Set backend
lumin.set_backend("cpu") # CPU backend (always available)
lumin.set_backend("openmp") # OpenMP backend (if available)
lumin.set_backend("cuda") # CUDA backend (if available)
lumin.set_backend("mpi") # MPI backend (if available)
API Reference
Matrix Class
Constructors
Matrix()- Create empty matrixMatrix(rows, cols)- Create matrix with specified dimensions (filled with zeros)Matrix(numpy_array)- Create matrix from NumPy array
Properties
rows()- Get number of rowscols()- Get number of columnsshape- Get (rows, cols) tuple
Methods
add(other)- Add another matrixsubtract(other)- Subtract another matrixmultiply(other)- Matrix multiplicationscalar(s)- Multiply by scalartranspose()- Transpose the matrixdot(other)- Compute dot product with another matrixto_numpy()- Convert matrix to NumPy array
Operators
A + B- Matrix additionA - B- Matrix subtractionA * B- Matrix multiplicationA * sors * A- Scalar multiplicationA % B- Dot productA[i, j]- Element access (get/set)
Static Methods
Matrix.random_int(rows, cols, max_value=100)- Create matrix with random integer values
Backend Functions
create_cpu_backend()- Create CPU backendcreate_omp_backend()- Create OpenMP backend (if available)create_cuda_backend()- Create CUDA backend (if available)create_mpi_backend(comm=0)- Create MPI backend (if available)set_default_backend(backend)- Set default backendget_default_backend()- Get current default backendset_backend(name)- Set backend by name ("cpu", "openmp", "cuda", "mpi")
Backends
CPU Backend
Always available. Single-threaded CPU operations.
lumin.set_backend("cpu")
OpenMP Backend
Parallel CPU operations using OpenMP. Automatically enabled if OpenMP is available.
lumin.set_backend("openmp")
CUDA Backend
GPU acceleration using NVIDIA CUDA. Requires CUDA toolkit and compatible GPU.
lumin.set_backend("cuda")
MPI Backend
Distributed computing using MPI. Requires MPI library (e.g., OpenMPI, MPICH).
lumin.set_backend("mpi")
Examples
See python/example.py for a complete example.
Basic Operations
import lumin
# Create and fill matrices
A = lumin.Matrix(2, 2)
A[0, 0] = 1.0
A[0, 1] = 2.0
A[1, 0] = 3.0
A[1, 1] = 4.0
B = lumin.Matrix(2, 2)
B[0, 0] = 5.0
B[0, 1] = 6.0
B[1, 0] = 7.0
B[1, 1] = 8.0
# Operations
C = A + B
D = A * B
E = A.transpose()
NumPy Integration
import numpy as np
import lumin
# Create from NumPy
arr = np.random.rand(100, 100)
matrix = lumin.Matrix(arr)
# Convert back
result = matrix.to_numpy()
Backend Selection
import lumin
# Try different backends
backends = ["cpu", "openmp", "cuda", "mpi"]
for backend_name in backends:
try:
lumin.set_backend(backend_name)
print(f"✓ {backend_name} backend available")
except Exception as e:
print(f"✗ {backend_name} backend not available: {e}")
Building from Source
Prerequisites
- CMake 3.16+
- C++17 compatible compiler
- Python 3.6+
- NumPy
- pybind11
Optional:
- OpenMP
- CUDA Toolkit
- MPI (OpenMPI or MPICH)
Build Steps
# Clone repository
git clone <repository-url>
cd LUMIN
# Install build dependencies
pip install scikit-build-core pybind11 numpy
# Build and install
pip install -e .
# Or build wheel
python -m build
Building Tests
Tests are disabled by default. To build and run tests:
mkdir build
cd build
cmake .. -DENABLE_TESTS=ON
make
ctest
Development
Project Structure
LUMIN/
├── include/ # C++ headers
│ └── lumin/
├── src/ # C++ source files
│ └── backends/
├── python/ # Python bindings
│ ├── bindings.cpp
│ └── example.py
├── tests/ # Test suite
├── CMakeLists.txt # CMake configuration
├── pyproject.toml # Python package configuration
└── setup.py # Setup script
Running Tests
cd build
ctest # Run all tests
ctest -R test_cpu # Run CPU tests only
ctest -R test_cuda # Run CUDA tests only
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details.
Changelog
See CHANGELOG.md for a list of changes in each version.
Links
Author
Philip Wisniewski
Metadata
Release files for lumin-matrix 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| lumin_matrix-0.1.3.tar.gz | 80.3 kB | Without provenance | Details |
Release files / lumin_matrix-0.1.3.tar.gz
| Download URL | lumin_matrix-0.1.3.tar.gz |
|---|---|
| Size | 80.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d03b5396f276deae0f3e914bffcb3560a3951b42052589af42e0bf8e5383437a
|
|
BLAKE2b-256 checksum How to use checksums |
21826e51de1ae173d96c5e5093e3abdee597607e763cc0eab2acd2bef3603d8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for lumin-matrix 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.