| Crates.io | numrst |
| lib.rs | numrst |
| version | 0.5.0 |
| created_at | 2025-08-25 10:58:12.082311+00 |
| updated_at | 2025-09-04 00:15:06.699493+00 |
| description | Fundamental package for scientific computing |
| homepage | |
| repository | https://github.com/MoleSir/numrst.git |
| max_upload_size | |
| id | 1809360 |
| size | 493,531 |
NumRst is a Rust implementation of multi-dimensional arrays (NdArray) and numerical computation, inspired by NumPy.
It provides a rich set of numerical operations, including broadcasting, indexing, matrix operations, reductions, logical and comparison ops, aiming to build a high-performance numerical computing tool in the Rust ecosystem.
Data types supported: Bool, U8, I8, U16, I16, U32, I32, USize, F32, F64
Operators & Arithmetic:
+ - / minimum maximumeq ne lt le gt geand or xorexp sin cos sqrt tanh floor ceil round abs neg lnNdArray operations:
reshape, transpose, squeeze, unsqueeze, narrow, narrow_range, repeat, flatten, splitcat, stackBroadcasting: NumPy-like broadcasting (broadcast_add, broadcast_sub, etc.)
Reductions:
sum, product, min, max, mean, var, stdsum_axis, max_axis, argmax_axis, etc.Array creation:
zeros, ones, arange, rand, randn, trues, falsesfrom_vec, full, newIndexing & slicing:
arr.index(2)?arr.index(rng!(1:3))?arr.index((rng!(1:3), .., 1..2))?Matrix operations:
matmulFile format:
View:
MatrixView and MatrixViewMutMatrixView and MatrixViewMutMatrixViewUsf and VectorViewUsf are unsafe view, use ptr as storageLinear algebra:
dot, matmul, trace, det, ranklu, qr, cholesky, bidiagonallu, qr, cholesky, eig(only support symmetric), svdplu_inv, qr_inv, cholesky_inv and inv(using solve)use numrst::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a 5x5x5 zero array
let arr = NdArray::<u32>::zeros((5, 5, 5))?;
// Basic arithmetic
let b = NdArray::<u32>::ones((5, 5, 5))?;
let c = arr.add(&b)?;
// Indexing and slicing
let sub_arr = c.index((rng!(1:3), .., 2))?;
// Matrix multiplication
let m1 = NdArray::<f32>::rand(0.0, 1.0, (3, 4))?;
let m2 = NdArray::<f32>::rand(0.0, 1.0, (4, 5))?;
let m3 = m1.matmul(&m2)?;
println!("Result shape: {:?}", m3.shape());
Ok(())
}
MIT