https://github.com/mjovanc/numru
A high-performance numeric computation library.
https://github.com/mjovanc/numru
numru rust
Last synced: 11 days ago
JSON representation
A high-performance numeric computation library.
- Host: GitHub
- URL: https://github.com/mjovanc/numru
- Owner: mjovanc
- License: mit
- Created: 2025-01-28T14:27:15.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-02-17T08:29:40.000Z (about 2 months ago)
- Last Synced: 2025-02-23T00:38:51.730Z (about 2 months ago)
- Topics: numru, rust
- Language: Rust
- Homepage: https://numru.rs
- Size: 113 KB
- Stars: 111
- Watchers: 3
- Forks: 29
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust - mjovanc/numru - A high-performance scientific computation library. (Libraries / Data processing)
- fucking-awesome-rust - mjovanc/numru - A high-performance scientific computation library. (Libraries / Data processing)
- awesome-ccamel - mjovanc/numru - A high-performance numeric computation library. (Rust)
README
# numru


[](https://docs.rs/numru/latest/)A high-performance numeric computation library written in Rust.
## Motivation
Numru is a numeric computation library that aims to provide a high-performance, easy-to-use, and flexible API for numerical operations.
It is inspired by NumPy, a popular numerical computation library in Python. Numru is designed to be a fundamental library for numeric computing with Rust.## Get Started
This getting started guide might change and should not be a source of absolute truth.
Check the unit tests and in `examples` if you want to stay up to date with how things should be done. Some APIs will most likely be changed in the future.```toml
[dependencies]
numru = "0.2.0"
```And a simple code:
```rust
use numru::arr;
use std::f64::consts::{E, PI, TAU};fn main() {
let a = arr![42, -17, 256, 3, 99, -8];
println!("a.shape() = {:?}", a.shape());
a.visualize().execute();let b = arr![[TAU, -PI, 1.61], [E, 0.98, -7.42], [4.67, -0.45, 8.88]];
println!("\nb.shape() = {:?}", b.shape());
b.visualize()
.decimal_points(1)
.execute();let c = arr![
[[101, 202, 303], [404, 505, 606]],
[[-707, -808, -909], [111, 222, 333]]
];
println!("\nc.shape() = {:?}", c.shape());
c.visualize().execute();
}
```Output of the code above:
```shell
a.shape() = Ix { dims: [6] }
[42, -17, 256, 3, 99, -8]b.shape() = Ix { dims: [3, 3] }
[
[6.3, -3.1, 1.6 ]
[2.7, 1.0 , -7.4]
[4.7, -0.5, 8.9 ]
]c.shape() = Ix { dims: [2, 2, 3] }
[
[
[101 , 202 , 303 ]
[404 , 505 , 606 ]
]
[
[-707, -808, -909]
[111 , 222 , 333 ]
]
]
```## Features
Numru will offer a variety of different numerical operations and data types. It is intended to be a fundamental library for numeric computing with Rust.
### Supported Data Types
- i64
- f64### Planned Data Types (Future)
- i8, i16, i32, i128
- u8, u16, u32, u64, u128
- f32
- bool
- String, &str### Supported Operations
Note that currently we only show the numru equivalents as the ones that are planned. They do not exist yet.
| **Operation** | **Type** | **NumPy Equivalent** | **Numru Equivalent** |
|--------------------|-------------------|-----------------------------|------------------------------|
| Create Array | Array Creation | `np.array([1, 2, 3])` | `arr![1, 2, 3]` |
| Zeros Array | Array Creation | `np.zeros((3,3))` | `zeros!(i64, 3, 3)` |
| Ones Array | Array Creation | `np.ones((3,3))` | `ones!(i64, 3, 3)` |
| Arange | Array Creation | `np.arange(start, stop, step)` | 🚧 |
| Linspace | Array Creation | `np.linspace(start, stop, num)` | 🚧 |
| Mean | Reduction | `np.mean(a)` | `a.mean().compute()` |
| Min | Reduction | `np.min(a)` | `a.min().compute()` |
| Max | Reduction | `np.max(a)` | `a.max().compute()` |
| Dot Product | Linear Algebra | `np.dot(a, b)` | 🚧 |
| Reshape | Manipulation | `a.reshape((4, 3, 3))` | 🚧 |
| Concatenate | Manipulation | `np.concatenate([a, b], axis=0)` | 🚧 |
| Element-wise Add | Element-wise Ops | `a + b` | 🚧 |
| Element-wise Sub | Element-wise Ops | `a - b` | 🚧 |
| Element-wise Mul | Element-wise Ops | `a * b` | 🚧 |
| Element-wise Div | Element-wise Ops | `a / b` | 🚧 |### Utility Features
These utility features help with visualization, debugging, array exploration and more.
| **Feature** | **Type** | **Numru** | **Description** |
|----------------------|-------------------|--------------------------------------------|--------------------------------------------------|
| Visualization | Visualization | `a.visualize().execute()` | Print an array in a human-readable format |
| Shape Inspection | Introspection | `a.shape()` | Get the shape of the array |
| Data Type Check | Introspection | `a.dtype()` | Retrieve the data type of the array |## License
The MIT License.