leto-ops
Math, reduction, SIMD, and parallel kernels for leto
arrays.
leto-ops is the compute half of the Leto workspace. It
adds elementwise arithmetic, reductions, matrix multiplication, dense linear
algebra, sparse formats and solvers, and CPU attention on top of the layout and
storage types leto defines.
use Array2;
use MatrixDecompose;
let a = from_shape_fn;
let qr = a.qr?;
# Ok::
What is here
- One generic
binary_map::<Op, T, N>traversal behindadd,sub,mul, anddiv, with broadcasting into a caller-owned output shape. - Strided map kernels derive cache-line micro-tiles from the process-cached
topology;
map_into_with_cache_geometryandbinary_map_with_cache_geometryaccept an explicit policy when external topology is authoritative. - Native
f32/f64paths route through Hermes SIMD, which runtime-dispatches AVX-512/AVX2/NEON with a scalar fallback. SIMD is not a build feature. ComplexLayout::transpose_complex_matricesmoves homogeneous row-major matrix batches into transposed caller-owned storage. Measured high-count small matrices use exact-width Hermes register tiles; other shapes call Leto's checked, cache-blockedtranspose_copydirectly, and underparallela batch of at least a mebibyte — one large matrix included — is written in tasks of whole destination rows.ComplexLayout::transpose_square_inplaceexchanges a complex square's rows and columns in borrowed storage, with checked extents and no allocation on success or rejection.SquareTransposeErrorretains overflowing sides or mismatched storage dimensions without changing the input. Movement preserves every scalar bit, including NaN payloads and signed zero.- Keep-dim axis reductions (
sum_axis,mean_axis,min_axis,max_axis) and their caller-owned*_intoforms, sharing one ZST-selected traversal. - Unary math markers (
ExpOp,LnOp,SqrtOp, …) over aRealScalarbound, plusmap_into/mapv/map/map_inplace. matmulandbatched_matmulwriting into caller-owned output, over contiguous and strided/transposed inputs.- Dense decompositions: LU (partial and full pivot), QR (Householder and
column-pivoted), Cholesky, UDU, Bunch-Kaufman, Hessenberg, bidiagonalization,
rank-revealing thin SVD, symmetric and Hermitian eigensolvers, the
general non-symmetric
eigenvalues, and realschur. - Direct solvers:
solve,solve_least_squares(column-pivoted QR), andpinv. Krylov recurrences live in Athena (Atlas ADR 0033), not here. - Sparse
CooMatrix/CsrMatrix/CscMatrixwithspmv,spmm,spgemm, and a sparse LU (SparseLuSolver). - A fluent rank-2 trait layer (
MatrixProduct,MatrixNorm,MatrixDecompose,MatrixSolve,MatrixProperties,MatrixFunction) whose methods are zero-cost delegators to the free-function kernels.
Runnable examples
Both are deterministic, CI-safe accuracy harnesses checked against analytically derived bounds, not benchmarks.
Documentation
API docs: https://docs.rs/leto-ops
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Complex movement binds statically through ComplexLayout. Generic callers add
T: ComplexLayout and invoke the operation on T; see
the migration contract.