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 ergonomics and user-friendliness while maintaining generality. Our goal is to make Rust a viable option for scripting and numerical analysis by creating a versatile and user-friendly tools.
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.cos;
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
- Scan right an left
let s = from;
let cumsum = s.scanr;
assert_eq!;
Dyatic 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
Complex numbers
You can ergonomically do operations between native numeric types and complex types C<T> with a simple and clean interface.
use *;
// Complex sclars
let z = 1 + 2.i;
assert_eq!;
assert_eq!;
Seamlessly work with complex numbers, and complex tensors.
use *;
// Complex tensors
let arr = from;
let arr_z = arr + -1 + 2.i;
assert_eq!;
assert_eq!;
Image to Array and Array to Image conversion
You can easily work with images of almost any format. rapl provides helpful functions to open images as both RGB and Luma Ndarr, and also save them to your preferred format.
use *;
use rapl_img;
Features in development:
- Native support for complex numbers.
- Port to stable Rust
- Line space and meshigrid initialization.
- Random array creation.
- 1D and 2D FFT.
- Matrix inversion.
- Image to array conversion.
- Array to image conversion.
- APL-inspired rotate function.
- Commonly use ML functions like Relu, Softmax etc.
- Support for existing plotting libraries in rust.
- Mutable slicing.
- Other Linear algebra functionalities: Eigen, LU, Gauss Jordan, Etc.
- Automatic differentiation.