gittech. site

for different kinds of informations and explorations.

Numru – A NumPy Equivalent in Rust

Published at
3 days ago

numru

ci crates.io documentation

A high-performance scientific computation library written in Rust.

Motivation

Numru is a scientific 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 scientific 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.

[dependencies]
numru = "0.2.0"

And a simple code:

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:

a.shape() = Shape=Ix { dims: [6] }
[42, -17, 256, 3, 99, -8]

b.shape() = Shape=Ix { dims: [3, 3] }
[
   [6.283185307179586, -3.141592653589793, 1.61 ]
   [2.718281828459045, 0.98              , -7.42]
   [4.67             , -0.45             , 8.88 ]
]

c.shape() = 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 scientific 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) 🚧
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.

Earn $100 Fast: AI + Notion Templates

Earn $100 Fast: AI + Notion Templates

Get the guide here

Do you want to make extra money quickly? This guide shows you how to create and sell Notion templates step by step. Perfect for beginners or anyone looking for an easy way to start earning online.

Why Download This Guide?

  • Start Making Money Fast: Follow a simple process to create templates people want and will buy.
  • Save Time with AI: Learn to use tools like ChatGPT to design and improve templates.
  • Join a Growing Market: More people are using Notion every day, and they need templates to save time and stay organized.

Includes Helpful Tools:

  • ChatGPT Prompts PDF: Ready-made prompts to spark ideas and create templates faster.
  • Checklist PDF: Stay on track as you work.

What’s Inside?

  • Clear Steps to Follow: Learn everything from idea to sale.
  • How to Find Popular Ideas: Research trends and needs.
  • Using AI to Create: Tips for improving templates with AI tools.
  • Making Templates User-Friendly: Simple tips for better design.
  • Selling Your Templates: Advice on sharing and selling on platforms like Gumroad or Etsy.
  • Fixing Common Problems: Solutions for issues like low sales or tricky designs.

Who Is This For?

  • Anyone who wants to make extra money online.
  • People who love using Notion and want to share their ideas.
  • Creators looking for a simple way to start selling digital products.

Get your copy now and start making money today!


πŸ’° Want to Earn 40% Commission?

Join our affiliate program and start making money by promoting well crafter prodicts! Earn 40% on every sale you refer.

πŸ”— Sign up as an affiliate here: Become an Affiliate