With v0.2.8, we have introduced robust numerical methods including LU and QR decompositions, Eigenvalue computations, and improved error handling for linear algebra operations.
- LU Decomposition: Implemented Gaussian elimination with partial pivoting for numerically stable
determinant,inverse, andrankcalculations. - QR Decomposition: Added
qr_decompositionfor QR decomposition. - Eigenvalues: Implemented
eigen(power iteration) andpower_methodfor eigenvalue and eigenvector computation. - Row Operations: Added
reduce_row_eliminationfor Gaussian elimination.
- Native Transpose Optimization: Matrix multiplication on Native backend now utilizes a transposition-based strategy, achieving >200% speedup for large matrices compared to naive methods.
- Zero-Overhead Construction:
Matrix::makeandMatrix::newrewritten to eliminate all division and modulo operations during initialization. - Hybrid Matrix Multiplication: Automatically switches between
i-j-k(register-optimized) andi-k-j(cache-friendly) strategies on other backends. - Secondary Utility Acceleration: Audited functions like
mapiandeach_row_colto eliminate division/modulo overhead (up to 60% faster). - Backend-Specific Optimization: Internal implementations are tailored for different targets (Wasm/JS vs. Native) to leverage specific engine strengths.
- Zero-Copy Transpose: Optimized identity-based multiplication and materialization.
- Consistent API: No matter which backend you target, the high-level API remains the same.
- Random Access: For high-performance scenarios requiring frequent random access, we strongly recommend using the
.get(i, j)and.set(i, j, val)methods directly. These avoid the overhead ofLensallocation and are the fastest way to interact with elements. - Bulk Operations: Prefer built-in tools like
.each_row_col()or.map_inplace()over manual loops with indexing for maximum optimization.
- Mutable & Immutable Support: Full suites for both
MatrixandVectortypes. - Advanced Operations: Includes LU/QR decomposition, determinant, inverse, rank, eigenvalues, and more.
- Zero-Cost Abstractions: Efficient
Transposeviews andLens-based row access. - Correctness First: Rigorous testing including edge cases (empty matrices, etc.).
Comprehensive API documentation is available at mooncakes.io.
We provide documentation in multiple languages:
- 🇺🇸 English (
doc/en_US) - 🇨🇳 简体中文 (
doc/zh_CN) - 🇯🇵 日本語 (
doc/ja_JP)
- Algorithms (0.2.8):
- ✨ Decompositions: Added LU (internal for Det/Rank), QR, and Eigenvalue decompositions.
- ✨ Stability: Shifted
determinantandrankto use partial pivoting LU for better numerical stability.
- Native Optimization (0.2.7):
- 🚀 Matrix Multiplication: Implemented transposition + dot-product strategy for Native, outperforming naive implementations by >2x.
- 🚀 Matrix Construction: Optimized
make,new,transposeto use direct loop unrolling and Array ops, removing expensive integer division. - 📝 Docs: Clarified
Lensvsget/setusage for performance-critical code.
- Performance Overhaul (0.2.4):
- 🚀 Optimized secondary utilities (
mapi,each_row_col, etc.). - 🚀 Hybrid Matrix multiplication (register and cache aware).
- 🚀 Accelerated Vector dot product and linear combinations.
- 🚀 Optimized secondary utilities (
- Renaming:
map_row()/map_col()->map_row_inplace()/map_col_inplace()eachij()->each_row_col()
- Fixes:
- Corrected determinant for 0x0 matrices.
- Fixed copy-on-conversion behavior between vectors and matrices.