• Stars
    star
    373
  • Rank 114,600 (Top 3 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rust numeric library with R, MATLAB & Python syntax

Peroxide

On crates.io On docs.rs

builds.sr.ht status travis github

maintenance

Rust numeric library contains linear algebra, numerical analysis, statistics and machine learning tools with R, MATLAB, Python like macros.

Why Peroxide?

1. Customize features

Peroxide provides various features.

  • default - Pure Rust (No dependencies of architecture - Perfect cross compilation)
  • O3 - BLAS & LAPACK (Perfect performance but little bit hard to set-up - Strongly recommend to look Peroxide with BLAS)
  • plot - With matplotlib of python, we can draw any plots.
  • nc - To handle netcdf file format with DataFrame
  • csv - To handle csv file format with Matrix or DataFrame
  • parquet - To handle parquet file format with DataFrame
  • serde - serialization with Serde.

If you want to do high performance computation and more linear algebra, then choose O3 feature. If you don't want to depend C/C++ or Fortran libraries, then choose default feature. If you want to draw plot with some great templates, then choose plot feature.

You can choose any features simultaneously.

2. Easy to optimize

Peroxide uses 1D data structure to describe matrix. So, it's too easy to integrate BLAS. It means peroxide guarantees perfect performance for linear algebraic computations.

3. Friendly syntax

Rust is so strange for Numpy, MATLAB, R users. Thus, it's harder to learn the more rusty libraries. With peroxide, you can do heavy computations with R, Numpy, MATLAB like syntax.

For example,

#[macro_use]
extern crate peroxide;
use peroxide::prelude::*;

fn main() {
    // MATLAB like matrix constructor
    let a = ml_matrix("1 2;3 4");

    // R like matrix constructor (default)
    let b = matrix(c!(1,2,3,4), 2, 2, Row);

    // Or use zeros
    let mut z = zeros(2, 2);
    z[(0,0)] = 1.0;
    z[(0,1)] = 2.0;
    z[(1,0)] = 3.0;
    z[(1,1)] = 4.0;
    
    // Simple but effective operations
    let c = a * b; // Matrix multiplication (BLAS integrated)

    // Easy to pretty print
    c.print();
    //       c[0] c[1]
    // r[0]     1    3
    // r[1]     2    4

    // Easy to do linear algebra
    c.det().print();
    c.inv().print();

    // and etc.
}

4. Can choose two different coding styles.

In peroxide, there are two different options.

  • prelude: To simple use.
  • fuga: To choose numerical algorithms explicitly.

For examples, let's see norm.

In prelude, use norm is simple: a.norm(). But it only uses L2 norm for Vec<f64>. (For Matrix, Frobenius norm.)

#[macro_use]
extern crate peroxide;
use peroxide::prelude::*;

fn main() {
    let a = c!(1, 2, 3);
    let l2 = a.norm();      // L2 is default vector norm
    
    assert_eq!(l2, 14f64.sqrt());
}

In fuga, use various norms. But you should write longer than prelude.

#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;
   
fn main() {
    let a = c!(1, 2, 3);
    let l1 = a.norm(Norm::L1);
    let l2 = a.norm(Norm::L2);
    let l_inf = a.norm(Norm::LInf);
    assert_eq!(l1, 6f64);
    assert_eq!(l2, 14f64.sqrt());
    assert_eq!(l_inf, 3f64);
}

5. Batteries included

Peroxide can do many things.

  • Linear Algebra
    • Effective Matrix structure
    • Transpose, Determinant, Diagonal
    • LU Decomposition, Inverse matrix, Block partitioning
    • QR Decomposition (O3 feature)
    • Singular Value Decomposition (SVD) (O3 feature)
    • Cholesky Decomposition (O3 feature)
    • Reduced Row Echelon form
    • Column, Row operations
    • Eigenvalue, Eigenvector
  • Functional Programming
    • More easy functional programming with Vec<f64>
    • For matrix, there are three maps
      • fmap : map for all elements
      • col_map : map for column vectors
      • row_map : map for row vectors
  • Automatic Differentiation
    • Taylor mode Forward AD - for nth order AD
    • Exact jacobian
    • Real trait to constrain for f64 and AD (for ODE)
  • Numerical Analysis
    • Lagrange interpolation
    • Splines
      • Cubic Spline
      • Cubic Hermite Spline
        • Estimate slope via Akima
        • Estimate slope via Quadratic interpolation
    • Non-linear regression
      • Gradient Descent
      • Levenberg Marquardt
    • Ordinary Differential Equation
      • Euler
      • Runge Kutta 4th order
      • Backward Euler (Implicit)
      • Gauss Legendre 4th order (Implicit)
    • Numerical Integration
      • Newton-Cotes Quadrature
      • Gauss-Legendre Quadrature (up to 30 order)
      • Gauss-Kronrod Quadrature (Adaptive)
        • G7K15, G10K21, G15K31, G20K41, G25K51, G30K61
    • Root Finding
      • Bisection
      • False Position (Regula Falsi)
      • Secant
      • Newton
  • Statistics
    • More easy random with rand crate
    • Ordered Statistics
      • Median
      • Quantile (Matched with R quantile)
    • Probability Distributions
      • Bernoulli
      • Uniform
      • Binomial
      • Normal
      • Gamma
      • Beta
      • Student's-t
    • RNG algorithms
      • Acceptance Rejection
      • Marsaglia Polar
      • Ziggurat
      • Wrapper for rand-dist crate
    • Confusion Matrix & Metrics
  • Special functions
    • Wrapper for puruspe crate (pure rust)
  • Utils
    • R-like macro & functions
    • Matlab-like macro & functions
    • Numpy-like macro & functions
    • Julia-like macro & functions
  • Plotting
    • With pyo3 & matplotlib
  • DataFrame
    • Support various types simultaneously
    • Read & Write csv files (csv feature)
    • Read & Write netcdf files (nc feature)
    • Read & Write parquet files (parquet feature)

6. Compatible with Mathematics

After 0.23.0, peroxide is compatible with mathematical structures. Matrix, Vec<f64>, f64 are considered as inner product vector spaces. And Matrix, Vec<f64> are linear operators - Vec<f64> to Vec<f64> and Vec<f64> to f64. For future, peroxide will include more & more mathematical concepts. (But still practical.)

7. Written in Rust

Rust & Cargo are awesome for scientific computations. You can use any external packages easily with Cargo, not make. And default runtime performance of Rust is also great. If you use many iterations for computations, then Rust become great choice.

Latest README version

Corresponding to 0.32.0

Pre-requisite

  • For O3 feature - Need OpenBLAS
  • For plot feature - Need matplotlib of python
  • For nc feature - Need netcdf

Install

  • Run below commands in your project directory
  1. Default
    cargo add peroxide
  2. OpenBLAS
    cargo add peroxide --features O3
  3. Plot
    cargo add peroxide --features plot
  4. NetCDF dependency for DataFrame
    cargo add peroxide --features nc
  5. CSV dependency for DataFrame
    cargo add peroxide --features csv
  6. Parquet dependency for DataFrame
    cargo add peroxide --features parquet
  7. All features
    cargo add peroxide --features "O3 plot nc csv parquet"

Useful tips for features

  • If you want to use QR or SVD or Cholesky Decomposition then should use O3 feature (there are no implementations for these decompositions in default)
  • If you want to write your numerical results, then use parquet or nc features (corresponding to parquet or netcdf format. (It is much more effective than csv and json.)
  • To plot, use parquet or nc feature to export data as parquet or netcdf format and use python to draw plot.
    • plot feature has limited plot abilities.
    • To read parquet file in python, use pandas & pyarrow libraries.
    • There is a template of python code for netcdf. - Socialst

Module Structure

Documentation

  • On docs.rs

Example

Peroxide Gallery

Version Info

To see RELEASES.md

Contributes Guide

See CONTRIBUTES.md

TODO

To see TODO.md

More Repositories

1

Zellaygen

Zellij Layout Generator
Rust
23
star
2

Peroxide_Gallery

Examples of Peroxide (Rust numeric library)
Rust
10
star
3

puruspe

PURe RUSt SPEcial library
Rust
10
star
4

Socialst

Axect's Customization Files
TeX
9
star
5

HNumeric

Haskell Numeric Library (Pure Functional, MATLAB & R Syntax)
Haskell
8
star
6

NCDataFrame.jl

Read & write netcdf file via DataFrames
Julia
5
star
7

QuantumAlgorithms

Implementations of Quantum Algorithms
Jupyter Notebook
5
star
8

Issues

Solve issues for various fields
4
star
9

Euler

Answer for Euler project using various languages (primary: Haskell, Rust, Nim)
Rust
4
star
10

DNumeric

D language Numerical Computation Repository
D
4
star
11

RGE

Go & Julia package to solve Renormalization Group Equation
Go
4
star
12

Scientific_Bench

Benchmark some scientific computations for various languages & libraries
Rust
4
star
13

Noisy_Regression

Noisy regression (MLP, BNN-(RVI, LA))
Jupyter Notebook
4
star
14

Neural_Hamilton

Official implementation of the paper "Neural Hamilton: Can A.I. Understand Hamiltonian Mechanics?"
Python
3
star
15

Quantauri_old

Quant alpha test
Rust
3
star
16

NiMusic

Nim Music Download Program for Youtube
Nim
3
star
17

axect.github.io_hugo

Axect's Blog
HTML
3
star
18

Rust

Rust Tutorial
Rust
3
star
19

Julia

Julia Tutorial & Projects
Jupyter Notebook
3
star
20

JuliaDocker

Docker Image for Julia scientific computing & ML
Julia
3
star
21

Forger

Forger: Reinforcement Learning Library in Rust
Rust
3
star
22

PL2020

Programming Lecture in 2020
Jupyter Notebook
3
star
23

Puruda

PUre RUst DAtaframe
Rust
3
star
24

HyperbolicLR

Hyperbolic Learning Rate Scheduler
Python
2
star
25

PyTorch_Derivative_Test

Python
2
star
26

ML_with_Rust

CSS
2
star
27

HRemember

Haskell program to support your memorization
Haskell
2
star
28

jeanychan

Jeanychanbang Masan Web page
HTML
2
star
29

HTEPS

Haskell TEPS words repo (using github.com/Axect/HWord)
Haskell
2
star
30

FPTools

Functional Programming and Efficient Tools for D
D
2
star
31

Pennylane_tutorial

Jupyter Notebook
2
star
32

Radient

Reverse mode Automatic Differentiation in Rust
Rust
2
star
33

HEP-COSMO

Administrate HEP-COSMO server
2
star
34

Natural_Unit

Physical unit conversion with Fundamental constants
Rust
2
star
35

ML_Project

Machine Learning Project with various language
TeX
2
star
36

Anomalocaris

Rust wrapper of Armadillo
Rust
2
star
37

Study2022

Study in 2022
HTML
2
star
38

KDE_from_scratch

Kernel Density Estimation from scratch in Rust
Rust
2
star
39

Peroxide_BLAS

Peroxide with BLAS example repo
Rust
2
star
40

Rustag

Rustag, a Rust-built command-line tool, simplifies file organization through custom tagging and swift fuzzy search, enhancing file management directly from your terminal.
Rust
2
star
41

Qeji

Jupyter Notebook
2
star
42

DeepONet_from_scratch

Tutorial for DeepONet
Jupyter Notebook
2
star
43

CosmoTransitions_tutorial

Jupyter Notebook
1
star
44

BSpline

Implement B-Spline from scratch in rust
Rust
1
star
45

Tina_Hugo_Tutorial

Tina + Hugo
CSS
1
star
46

JAX_Template

Python
1
star
47

SplineLR

Concept for SplineLR
Rust
1
star
48

Numeric

Go Package for Numerical Calculations
Go
1
star
49

hugo_blog

Axect's Blog
HTML
1
star
50

cv

HTML
1
star
51

DeepONet_Template

Python
1
star
52

Chapel

Chapel Study repo
Chapel
1
star
53

csv

Golang package to write or read csv wrt string array
Go
1
star
54

Go

Go Tutorial & Projects & Packages
Go
1
star
55

PyTorchDocker

Dockerfile
1
star
56

SNN_Gallery

Tutorial & Toy Project with SNN
Jupyter Notebook
1
star
57

FP-Lecture

2018 Functional Programming Lecture in Yonsei Univ
HTML
1
star
58

PML

Implement toy model for Parameterized Machine Learning for HEP
Jupyter Notebook
1
star
59

hepframework

Guide line of docker repository: axect/hepframework
Shell
1
star
60

VueFire

Vue.js + Firebase Study Repo
JavaScript
1
star
61

Asymptote

Asymptote tutorial
Asymptote
1
star
62

D

D Study Repo
D
1
star
63

Hydrogen_Peroxide

Rust
1
star
64

HWord

Haskell English Word Memorize Program
Haskell
1
star
65

fmp-rs

Financial Modeling Prep in Rust
Rust
1
star
66

Axect_Blog

Axect blog generator
Rust
1
star
67

Haskell

Haskell Repo
Haskell
1
star
68

Webtutorial

Django Tutorial
Python
1
star
69

Rustube

Rust youtube mp3 downloader
Rust
1
star
70

LaTeX

LaTeX Repository
TeX
1
star
71

HEP_Web_Django

Make HEP-COSMO site with Django framework
CSS
1
star
72

Yonsei-Flexible

μ—°μ„ΈλŒ€ν•™κ΅ μ „λ¬Έμ—°κ΅¬μš”μ› μœ μ—°κ·Όλ¬΄μ œ μ‹œκ°„ 계산기
Rust
1
star
73

Qiskit_Tutorial

Jupyter Notebook
1
star
74

DistributionalRL

Rust
1
star
75

Nim

Nim Tutorial Repo
Nim
1
star
76

Peroxide_Doc_Surge

Documents of Peroxide
HTML
1
star
77

Anomaly_thresholding

Toy experiment for thresholding method to detect anomaly
Python
1
star
78

least_action_old

Algorithmic Approach to Least Action Principle
Rust
1
star
79

ESL_Study

"Elements of Statistical Learning" Study Repo
Jupyter Notebook
1
star
80

HEP_CS

Study numerical algorithm
Python
1
star
81

Woroxide

Rust Word memorize program
Rust
1
star
82

Pylab_Template

Matplotlib template
Python
1
star
83

Manim_tutorial

Manim tutorial
Python
1
star
84

Python

Python study repo
Jupyter Notebook
1
star
85

DeepXDE_Tutorial

Jupyter Notebook
1
star
86

MITP2023

For 2023 summer school of Mainz Institute for Theoretical Physics
Jupyter Notebook
1
star
87

ax_tutorial

Jupyter Notebook
1
star
88

pytorch_template

Python
1
star
89

Rugfield

Rust Gaussian Random Field
Rust
1
star
90

Noisy_Candle

A Rust project showcasing regression on noisy data using machine learning libraries.
Rust
1
star
91

Neural_Hamilton_old

Use DeepONet to solve Hamilton equations
Jupyter Notebook
1
star
92

GRF_test

Generate Gaussian Random Fields
Rust
1
star
93

Axect_Blog_Gen

JavaScript
1
star