Ultimate Industrial Matrix Library - High Performance C++ with Python Bindings
Project description
Industrial Matrix
High-performance matrix computing library with SIMD optimization and OpenMP parallelization.
Features
- SIMD Optimization: AVX2 vectorized operations for maximum performance
- OpenMP Parallelization: Multi-threaded matrix multiplication and operations
- NumPy Integration: Seamless conversion between NumPy arrays and Matrix objects
- Multiple Data Types: Support for float32, float64, int32, and int64
- Modern C++17: Clean, efficient implementation with PIMPL pattern
Installation
Prerequisites
sudo apt-get update
sudo apt-get install -y python3-dev python3-pip build-essential
Install from source
pip install pybind11 numpy
python setup.py build_ext --inplace
python setup.py install
Or use pip in development mode:
pip install -e .
Quick Start
import industrial_matrix as im
import numpy as np
# Check system capabilities
print(im.system_info())
# Create matrices
A = im.MatrixF64.random(1000, 1000)
B = im.MatrixF64.ones(1000, 1000)
# Matrix operations
C = A @ B # Matrix multiplication
D = A + B # Element-wise addition
E = A.transpose()
# NumPy interoperability
np_array = np.random.rand(100, 100)
matrix = im.MatrixF64.from_numpy(np_array)
result = matrix.to_numpy()
# Benchmark
stats = im.benchmark(size=512, trials=10)
print(f"Performance: {stats['gflops']:.2f} GFLOPS")
Performance
The library uses block-based matrix multiplication with cache optimization and SIMD instructions:
- Single-threaded: ~10-30 GFLOPS (depends on CPU)
- Multi-threaded: Scales linearly with core count
- SIMD: 4-8x speedup from AVX2 vectorization
API Reference
MatrixF64 / MatrixF32
Factory Methods
zeros(rows, cols)- Create zero matrixones(rows, cols)- Create matrix filled with onesidentity(n)- Create identity matrixrandom(rows, cols, min, max)- Create random matrix
Properties
rows()- Number of rowscols()- Number of columnsshape()- Tuple of (rows, cols)size()- Total number of elements
Operations
matrix_multiply(other)or@- Matrix multiplicationelementwise_add(other)or+- Element-wise additionelementwise_multiply(other)or*- Element-wise multiplicationtranspose()- Matrix transposescalar_multiply(scalar)- Scalar multiplication
Advanced Patterns
Scalar Addition Workaround
The library doesn't have a direct scalar_add method. To add a scalar to all elements:
# Add scalar value to all matrix elements
ones = im.MatrixF64.ones(rows, cols)
scalar_matrix = ones.scalar_multiply(5.0) # Create matrix of [5.0, 5.0, ...]
result = original_matrix.elementwise_add(scalar_matrix)
# Example: Add 10 to all elements
A = im.MatrixF64.random(100, 100)
offset = im.MatrixF64.ones(100, 100).scalar_multiply(10.0)
B = A.elementwise_add(offset)
NumPy Integration
from_numpy(array)- Convert NumPy array to Matrixto_numpy()- Convert Matrix to NumPy array
Requirements
- Python 3.7+
- NumPy 1.19.0+
- C++17 compatible compiler
- OpenMP support (optional, for parallelization)
- AVX2 CPU support (optional, for SIMD)
License
MIT License
Contributing
Contributions welcome! Please submit pull requests or open issues on GitHub.
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
File details
Details for the file update_industrial_matrix_ultimate-2.1.0.tar.gz.
File metadata
- Download URL: update_industrial_matrix_ultimate-2.1.0.tar.gz
- Upload date:
- Size: 26.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01064dac688e3ce965b2790d39f0227951a7e1dc581f9321364e6741f5dcb8c3
|
|
| MD5 |
8708791be59fac3fbfc3bc8a0e2131b6
|
|
| BLAKE2b-256 |
201e24cf46140bf10d52df2587f2d107410c06fdaaa9a6ace0c3b903d6f47b8c
|