rapl
NOTE: rapl requires Nightly and is strictly intended for non-production purposes only. rapl utilizes certain unstable features that may result in unexpected behavior, and is not optimized for performance.
rapl is an experimental numerical computing Rust library that provides a simple way of working with N-dimensional array, along with a wide range of mathematical functions to manipulate them. It takes inspiration from NumPy and APL, with the primary aim of achieving maximum ergonomic and user-friendliness while maintaining generality. Notably, it offers automatic Rank Polymorphic broadcasting between arrays of varying shapes and scalars as a built-in feature.
use *;
Array initialization
There are multiple handy ways of initializing N-dimensional arrays (or Ndarr).
- From Native Rust arrays to
Ndarr.
let a = from;
let b = from;
- From ranges.
let a = from.reshape
- From
&str
let chars = from; //Ndarr<char,1>
- Others:
let ones: = ones;
let zeros : = zeros;
let letter_a = fill;
let fold = new.expect;
Element wise operations
- Arithmetic operation with with scalars
let ones: = ones;
let twos = &ones + 1;
let sixes = &twos * 3;
- Arithmetic operation between
Ndarrs,
let a = from;
let b = from;
assert_eq!
Note: If the shapes are not equal rapl will automatically broadcast the arrays into a compatible shape (if it exist) and perform the operation.
- Math operations including trigonometric functions
let x = from;
let sin_x = &x.sin;
let cos_x = &x.sin;
let tanh_x = &x.tanh;
let abs_x = x.abs;
- Map function
let a = from;
let mapped = a.map;
Monadic tensor operations
- Transpose
let arr = from;
assert_eq!;
assert_eq!; //transpose
- Reshape
let a = from.reshape.unwrap;
- Slice
let arr = from;
assert_eq!
- Reduce
let sum_axis = arr.clone.reduce.unwrap;
assert_eq!; //sum reduction
Diatic tensor operations
- Generalized matrix multiplication between compatible arrays
use *
use ;
let a = from.reshape.unwrap;
let b = from.reshape.unwrap;
let matmul = mat_mul)
- APL inspired Inner Product.
let a = from.reshape.unwrap;
let b = from.reshape.unwrap;
let inner = inner_product;
assert_eq!
- Outer Product.
let suits = from;
let ranks = from;
let add_str = ;
let deck = outer_product.flatten; //All cards in a deck
Features in development:
- Port to stable Rust
- Line space and meshigrid initialization
- Range support for floating types.
- Random array creation.
- 1D and 2D FFT.
- Matrix inversion.
- Image to array conversion.
- APL-inspired rotate function.
- Change Inner and Outer products to be higher-order functions.
- Add generalized diatic functions between scaler types.
- Commonly use ML functions like Relu, Softmax etc.
- Native support for complex numbers.
- Support for existing plotting libraries in rust.