Nabla-ML
Nabla-ML is a Rust library inspired by NumPy, providing a multi-dimensional array implementation with various mathematical and array manipulation functionalities.
Features
- Array Creation: Create 1D and 2D arrays using vectors and matrices.
- Random Arrays: Generate arrays with random numbers, including uniform and normal distributions.
- Arithmetic Operations: Perform element-wise addition, subtraction, multiplication, and division.
- Mathematical Functions: Apply functions like square root, exponential, sine, cosine, and logarithm to arrays.
- Array Reshaping: Change the shape of arrays while maintaining data integrity.
- Indexing and Slicing: Access and modify elements using indices and slices.
- Conditional Selection: Filter arrays based on conditions.
- Array Attributes: Retrieve attributes like number of dimensions, shape, size, and data type.
- Axis Manipulation: Add new axes to arrays to increase dimensionality.
Usage
Creating Arrays
use NDArray;
// Create a 1D array
let arr = from_vec;
// Create a 2D array
let mat = from_matrix;
Random Arrays
// Create a 1D array of random numbers between 0 and 1
let rand_arr = rand;
// Create a 2D array of random integers between 1 and 10
let rand_int_mat = randint_2d;
Arithmetic Operations
let arr1 = from_vec;
let arr2 = from_vec;
// Element-wise addition
let sum = arr1 + arr2;
// Scalar multiplication
let scaled = arr1 2.0;
Mathematical Functions
let arr = from_vec;
// Calculate square roots
let sqrt_arr = arr.sqrt;
// Calculate exponentials
let exp_arr = arr.exp;let arr = from_vec;
// Calculate square roots
let sqrt_arr = arr.sqrt;
// Calculate exponentials
let exp_arr = arr.exp;
Reshaping Arrays
let arr = from_vec;
let reshaped = arr.reshape;
Indexing and Slicing
let arr = from_vec;
// Access an element
let first = arr.get;
// Slice the array
let slice = arr.slice;
Conditional Selection
let arr = from_vec;
// Filter elements greater than 0.7
let filtered = arr.filter;
Array Attributes
let arr = from_matrix;
// Get number of dimensions
let ndim = arr.ndim;
// Get shape
let shape = arr.shape;
// Get size
let size = arr.size;
// Get data type
let dtype = arr.dtype;
Axis Manipulation
let arr = from_vec;
// Add a new axis
let row_vector = arr.new_axis;
let col_vector = arr.new_axis;
License
This project is licensed under the AGPL-3.0 License - see the LICENSE file for details.