Rust numeric library with R, MATLAB & Python syntax

Overview

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 - OpenBLAS (Perfect performance but little bit hard to set-up - Strongly recommend to read OpenBLAS for Rust)
  • 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
  • serde - serialization with Serde.

If you want to do high performance computation and more linear algebra, then choose openblas 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)
    • 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
    • Cubic spline
    • 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
  • 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)

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.30.2

Pre-requisite

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

Install

  • Add next block to your cargo.toml
  1. Default
    [dependencies]
    peroxide = "0.30"
  2. OpenBLAS
    [dependencies.peroxide]
    version = "0.30"
    default-features = false
    features = ["O3"] 
  3. Plot
    [dependencies.peroxide]
    version = "0.30"
    default-features = false
    features = ["plot"] 
  4. NetCDF dependency for DataFrame
    [dependencies.peroxide]
    version = "0.30"
    default-features = false
    features = ["nc"]
  5. CSV dependency for DataFrame
    [dependencies.peroxide]
    version = "0.30"
    default-features = false
    features = ["csv"]
  6. OpenBLAS & Plot & NetCDF
    [dependencies.peroxide]
    version = "0.30"
    default-features = false
    features = ["O3", "plot", "nc", "csv"] 

Useful tips for features

  • If you want to use QR or SVD then should use O3 feature (there are no implementations for these decompositions in default)
  • If you want to write your numerical results, then use nc feature and netcdf format. (It is much more effective than csv and json.)
  • To plot, use nc feature to export data as netcdf format and use python to draw plot.
    • plot feature has limited plot abilities.
    • There is a template of python code. - 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

Comments
  • Support for Windows?

    Support for Windows?

    Hello,

    I am trying my very first steps in Rust. Actually Peroxide is my first dependency I tried to include into my project. So, it may be a beginners mistake, but I really cannot make it work.

    Here is what I did:

    • Included the dependency like:
    [dependencies.peroxide]
    version = "0.21"
    default-features = false
    features = ["dataframe"]
    
    • Compiled (without problems). Cargo build fails with:

    = note: LINK : fatal error LNK1181: cannot open input file 'netcdf.lib'

    • Downloaded+Installed netcdf from

    https://www.unidata.ucar.edu/software/netcdf/docs/winbin.html

    • Built again, same problem
    • Added lib folder of netcdf manually to PATH
    • Double checked its availability
    > where netcdf.lib
    >> C:\Program Files\netCDF 4.7.4\lib\netcdf.lib
    
    • Cleaned the build (cargo clean)
    • built from scratch
    • Dependencies built again fine, particularly:

    Compiling netcdf v0.2.0

    • Linker still fails on
    error: linking with `link.exe` failed: exit code: 1181
      |
      = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\username\\.rustup\\toolchains\\stable-x86_6
    4-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.30i0fylwf8h8ulnx.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target
    \\debug\\deps\\hdtree_rust.3le9awyzz0gyzza3.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.3mz25962q1j46fjg.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\d
    eps\\hdtree_rust.4g9p2kmszo5plezg.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.4idues0eeqlb3xz9.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtre
    e_rust.5f0n4k1xtlm3wg9l.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.5ga6ebzlel6xoxwm.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.zvd
    o8rmrsj7qkqr.rcgu.o" "/OUT:C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.exe" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.29ih15nz8vqrgzu1.rcgu.o" "/OP
    T:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\l
    ib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-wind
    ows-msvc\\lib\\rustlib\\etc\\libstd.natvis" "/LIBPATH:C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps" "/LIBPATH:C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_
    64-pc-windows-msvc\\lib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libperoxide-24bf80c4ddf588c5.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libcsv-2b6c3aeb6abeb573.
    rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libryu-d56761e067164813.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libitoa-d7c651340e327dcf.rlib" "C:\\Users\\Richa
    rd\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libcsv_core-102be63259463331.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libbstr-d02df58ca68799e4.rlib" "C:\\Users\\username\\Dropbox\\dev\\
    hdtree_rust\\target\\debug\\deps\\libregex_automata-0dd02774b7688856.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libbyteorder-6de9b9e550938e5e.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_
    rust\\target\\debug\\deps\\libmemchr-e69b91a3f49b729c.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libserde-490de0045ee1405b.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug
    \\deps\\librand_distr-f3f2a9aeaf547929.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libmatrixmultiply-0a35a7d21257890c.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps
    \\librawpointer-c36da0366a5028e9.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libpuruspe-b3f6429c5fb8c975.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\liborder_st
    at-216e1fa5f5fd6ba9.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libjson-00767a04bcc14eb6.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libnetcdf-ab3a9c03658592ea.
    rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libnetcdf_sys-cae9d15dc48a360f.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\liblazy_static-14780178ad1d3bd0.rlib" "C:
    \\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libindexmap-bdaf8fd585f4cea4.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\librand-f1a6813f03c05795.rlib" "C:\\Users\\username\\
    Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\librand_chacha-511b7d3a4fe8a2e2.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libppv_lite86-0a2ecd567e7881db.rlib" "C:\\Users\\username\\Dropbox\\
    dev\\hdtree_rust\\target\\debug\\deps\\librand_core-5b1cbcc69748ae95.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libgetrandom-e0be2fffb9b435da.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_
    rust\\target\\debug\\deps\\libcfg_if-46d5a3a2d2fb8986.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-93a5cbf3214e1635.rlib" "C:\\Users\\Rich
    ard\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-bc497f38bc14ea36.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustl
    ib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-cff6a81a38e24acd.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-2fcb3fe3
    0807f5cb.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libbacktrace-916d55fe59b6e45e.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64
    -pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-7f1beeb3aa6031c7.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libu
    nwind-0f8323184fc867ad.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-451043412713beed.rlib" "C:\\Users\\username\\.rustup\\toolchains\\st
    able-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-e9eb82ffd1eb284e.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\lib
    alloc-8a93a70731c0c815.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-6fc8e09b7aa39aaf.rlib" "C:\\Users\\username\\.rust
    up\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-05a61bb76241250f.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-wind
    ows-msvc\\lib\\libcompiler_builtins-9e67ceffec35e0af.rlib" "netcdf.lib" "netcdf.lib" "advapi32.lib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "msvcrt.lib"
      = note: LINK : fatal error LNK1181: cannot open input file 'netcdf.lib'
    
    • Notice the double quoted entries at the end of the command like "netcdf.lib" "netcdf.lib" (which also appear for some reason twice?!)
      • At this point there are too many questions: What is generating the link command?
      • is it supposed to find the paths correctly alone?
      • why some entries are duplicated?
      • am I supposed to install the libs by hand at all?
      • if yes: how am I expected to exactly know which versions those should be?
      • how can I make cargo actually recognize them?
    • Too many questions -> Gave up and came here.

    Versions:

    cargo --version cargo 1.42.0 (86334295e 2020-01-31)

    rustc --version rustc 1.42.0 (b8cedc004 2020-03-09)

    (Windows 10)

    opened by Mereep 5
  • Print in ODE when stop condition is reached

    Print in ODE when stop condition is reached

    Hello, thank your for this nice crate. I have a minor issue that is not blocking or whatever. In the ODE method integrate there are printl when the stop condition is reached. I can understand why for debug purpose but when calling this method a lot of time, this end up making a lot of noise and slowing down the process. For example, my use case is a physical model being simulated several times to find the best parameters for a PID controller through black box optimization (differential evolution). The stop condition is used to eliminate parameters that do not satisfy the physical limits of my model (a motor that spins faster than the maximum angular speed allowed by the voltage supply for example). I end up with thousands of line printed by the stop condition which slow the process and make the interesting output difficult to identify. I would be up to write a small patch to fix this but i do not know how yet.

    The print is at this line: https://github.com/Axect/Peroxide/blob/892e224b4bfa997238203d1d677184a647d5e94b/src/numerical/ode.rs#L607

    enhancement 
    opened by tchamelot 4
  • LM Algorithm: Unbounded lambda

    LM Algorithm: Unbounded lambda

    I have some optimisations which appear to get caught in a local minimum so that chi = chi_2 and as a result rho = 0. In the current setup, the algorithm doubles lambda until there is some improvement, this seems to lead to divergence and the algorithm failing for some optimisation problems. A simple fix might be to have the algorithm halt when lambda exceeds a meaningful value.

    enhancement 
    opened by aiden-huffman 4
  • Documentation search results does not work

    Documentation search results does not work

    If one goes to the documentation, searches something, and clicks some search result, then "page not found" -page comes up.

    For example, clicking any search result on following site gives "page not found"-error: http://peroxide.info/?search=matrix

    opened by tolvanea 4
  • Add support of root-finding

    Add support of root-finding

    I use Peroxide for some number cruching. For example, my code interpolates a measurement series of an analogue-digital converter with a spline and it analyzes the first and second derivatives. Therefore, I need to find the root of these derivatives.

    However, there is no bisection or any other numerical root-find method in Peroxide and I have to use the rootfind crate but this crate is not actively maintained. Additionally, if root finding is provided by Peroxide, this would reduce the number of crate in my dependencies.

    enhancement 
    opened by schrieveslaach 3
  • Taylor mode automatic differentiation

    Taylor mode automatic differentiation

    Peroxide has two AD methods - Dual, HyperDual. But these are only 1st and 2nd order methods, and they are distinct. So, we need not only higher order AD but also generic.

    • [x] Struct AD
      • [x] fmt::Display
      • [x] Copy?
      • [x] From<T>
    • [x] std::ops for AD
      • [x] Add, Sub, Neg
      • [x] Mul
      • [x] Div
    • [x] PowOps for AD
      • [x] powi
      • [x] powf
      • [x] pow
    • [x] TrigOps for AD
      • [x] sin, cos, tan
      • [x] asin, acos, atan
      • [x] sinh, cosh, tanh
      • [x] asinh, acosh, atanh
      • [x] sin_cos, sinh_cosh
    • [x] ExpLogOps for AD
      • [x] exp, ln
      • [x] log, log2, log10
    • [x] std::ops with f64
      • [x] Add, Sub
      • [x] Mul, Div
    • [x] Change the structure - proc_macro to Enum (to reduce compile time)
    • [x] Generic AD function - ADFn
    • [x] Apply to numerical things
      • [x] numerical/root
      • [x] numerical/ode
      • [x] numerical/optimize
      • [x] numerical/utils
    enhancement 
    opened by Axect 3
  • Cubic Spline Struct

    Cubic Spline Struct

    Add a struct that holds the vector of polynomials of a natural cubic spline, providing additionally an eval function that uses binary search to find the correct polynomial for a given x.

    Additionally, the spline struct can be extended by new x and y values.

    enhancement 
    opened by schrieveslaach 3
  • Fix bug in rref() function

    Fix bug in rref() function

    Fixed an error in the function to find the reduced row echelon form of a matrix. This error causes the function to panic for certain matricies.

    The pseudocode at (https://rosettacode.org/wiki/Reduced_row_echelon_form) shows that if columnCount == lead, the function should stop. The old implementation used a break statement, which only broke out of the while loop at line 3310, where it should break out of the main for loop at line 3305. This is easily fixed by using named loops to break out of a specific loop.

    bug 
    opened by thettasch 2
  • `quantile` may panic

    `quantile` may panic

    #![feature(drain_filter)]
    
    #[macro_use]
    extern crate peroxide;
    use peroxide::fuga::*;
    use peroxide::statistics::*;
    
    use std::{env, ops::Index};
    
    fn main() -> Result<(), Box<dyn Error>> {
        let data = vec![0f64; 7592];
        let q = quantile(&data, QType::Type1);
        println!("{:?}", q);
        Ok(())
    }
    

    Panics with the following:

       Running `target\debug\o2ring.exe C:\Users\asm19\OneDrive\zettlekasten\o2ring\2021-03-28.csv`
    thread 'main' panicked at 'index out of bounds: the len is 7592 but the index is 7592', C:\Users\asm19\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\slice\mod.rs:566:36
    stack backtrace:
       0: std::panicking::begin_panic_handler
                 at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597\/library\std\src\panicking.rs:493
       1: core::panicking::panic_fmt
                 at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597\/library\core\src\panicking.rs:92
       2: core::panicking::panic_bounds_check
                 at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597\/library\core\src\panicking.rs:69
       3: core::slice::{{impl}}::swap<f64>
                 at C:\Users\asm19\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\slice\mod.rs:566
       4: order_stat::floyd_rivest::select_<f64,closure-0>
                 at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\order-stat-0.1.3\src\floyd_rivest.rs:37
       5: order_stat::floyd_rivest::select_<f64,closure-0>
                 at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\order-stat-0.1.3\src\floyd_rivest.rs:32
       6: order_stat::floyd_rivest::select<f64,closure-0>
                 at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\order-stat-0.1.3\src\floyd_rivest.rs:8
       7: order_stat::kth_by<f64,closure-0>
                 at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\order-stat-0.1.3\src\lib.rs:192
       8: peroxide::statistics::stat::quantile_mut
                 at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\peroxide-0.30.5\src\statistics\stat.rs:504
       9: peroxide::statistics::stat::{{impl}}::quantiles
                 at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\peroxide-0.30.5\src\statistics\stat.rs:485
      10: peroxide::statistics::stat::quantile
                 at C:\Users\asm19\.cargo\registry\src\github.com-1ecc6299db9ec823\peroxide-0.30.5\src\statistics\stat.rs:527
      11: o2ring::main
                 at .\src\main.rs:12
      12: core::ops::function::FnOnce::call_once<fn() -> core::result::Result<tuple<>, alloc::boxed::Box<Error, alloc::alloc::Global>>,tuple<>>
                 at C:\Users\asm19\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:227
    note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
    
    bug 
    opened by asmyers 2
  • Uniform random generator behaviour

    Uniform random generator behaviour

    I am not sure whether it is intended or not but

    Uniform(0,1) has type TPDist and Uniform(0,1).sample(10) type generates random integers between [0, 1), so only zeros

    However, Normal(0,1) has the same type TPDist and Nomral(0,1).sample(10) genrates random floats from the distribution

    opened by spar7453 2
  • The `rng` for various distributions should use those from `rand_distr` crate

    The `rng` for various distributions should use those from `rand_distr` crate

    rand_distr crate contains rng functions we need, and they use more efficient algorithms then we currently have.

    So consider making thin wrapper functions instead of writing our own rng instead.

    opened by lebensterben 2
  • Cholesky decomposition

    Cholesky decomposition

    Hey, thanks for the library, it's a pleasure to use.

    I was wondering whether there are any plans to implement Cholesky decomposition? I understand it's probably not a high priority as LU decomposition is already implemented, but would be cool to have some additional speed there!

    Thanks, Andrew

    enhancement 
    opened by AnBowell 3
  • Adaptive Differential Equation Solvers

    Adaptive Differential Equation Solvers

    Hey,

    Thanks for the wonderful library. Do you have plans of putting in adaptive solvers of differential equations? Would that require considerable changes to the current framework?

    Best, Amartya

    opened by amartyabose 3
  • Use FFT algorithm for faster polynomial multiplication

    Use FFT algorithm for faster polynomial multiplication

    This pull request will contain an implementation of the Cooley-Tukey Fast Fourier Transform algorithm, and use it to speed up polynomial multiplication for high degree polynomials. More information can be found in issue #45.

    This pull request will contain the following features:

    • [x] An implementation of the Fast Fourier Transform
    • [x] A modification to the polynomial multiplication code to use this algorithm for high degree polynomial multiplication
    • [x] Tests covering most vital functions to ensure proper functioning of multiplication
    • [ ] Benchmarking and optimizing the algorithm
    opened by jonasvanderschaaf 0
  • Faster polynomial multiplication

    Faster polynomial multiplication

    The current polynomial multiplication has a runtime of O(n^2). This is fine for some cases (especially lower degree polynomials), but is suboptimal, as it is relatively easy to reduce the runtime using a Fast Fourier Transformation to O(n log n). This would be a considerable speedup for higher degree polynomials.

    I think it would be best to perhaps use the currrent algorithm for polynomials of low degree, as it is undoubtedly faster for these kinds, but for higher degree polynomials switch to the more complex, but asymptotically faster FFT. The switching point should of course be determined by the implementation details.

    If this is something worth considering, I think there would be three ways to go about using this method:

    1. Use an existing FFT crate which is significantly faster than what would be used in this crate, which in turn significantly improve the runtime of many things using polynomials.
    2. Create a custom implementation of the FFT algorithm. This would mean that the crate has less dependencies, and would therefore be more portable.
    3. You could also possibly use a feature flag to indicate use of an external FFT library, which would include the best of both worlds: It would allow for people who need an efficient implementation to use the external library for the multiplication, and those who care more about portability to use the slower version.

    If you think that the second option sounds appealing, I would be willing to write an implementation of the algorithm.

    enhancement 
    opened by jonasvanderschaaf 3
  • Whole new numerical computations

    Whole new numerical computations

    There will be huge update in 0.31.0 - Algebraic Syntax Tree based Automatic Differentiation. Therefore, there will be significant changes in the numerical calculation API accordingly.

    1. Optimize (numeric/optimize.rs)
      • [ ] API Change
      • [ ] Documentation
      1. Zeroth order (Not relate to AD)
        • [ ] Bracket minimum
        • [ ] Shubert-Piyavskii
        • [ ] Fibonacci
        • [ ] Golden Section
        • [ ] Quadratic Fit
      2. First Order (Use ADScalarFn)
        • [ ] Bisection
        • [ ] Gradient Descent
        • [ ] Conjugate Gradient
        • [ ] Momentum
        • [ ] Nesterov Momentum
        • [ ] Adagrad
        • [ ] RMSprop
        • [ ] Adadelta
        • [ ] Adam
        • [ ] Hypergradient
    2. Regression (numeric/reg.rs)
      • [ ] API Change
      • [ ] Documentation
      1. Linear Regression
        • [ ] Ordinary Least Square
        • [ ] Ridge
        • [ ] LASSO
        • [ ] Principal Component Regression
      2. Nonlinear Regression
        • [ ] Gradient Descent
        • [ ] Gauss-Newton
        • [ ] Levenberg-Marquardt
    3. Root Finding (numeric/root.rs)
      • [ ] API Change
      • [ ] Documentation
      1. Bracketing
        • [ ] Bisection
        • [ ] False Position
        • [ ] Secant
      2. First Order
        • [ ] Newton-Raphson
    enhancement 
    opened by Axect 0
  • Optimization after refactoring to AD in 0.30 - example failing

    Optimization after refactoring to AD in 0.30 - example failing

    Hi, thanks a lot for the great library.

    I tried running the example in optimization.rs in 0.30.6 and it does not optimize, keeping the initial value in p output. Using 0.29.1 - its example (i.e. before refactoring from numbers to AD) works OK.

    Thanks a lot,

    Pavel.

    bug enhancement 
    opened by pavhofman 10
Owner
Tae Geun Kim
Ph.D student of particle physics & Rustacean
Tae Geun Kim
A Python CLI tool that finds all third-party packages imported into your Python project

python-third-party-imports This is a Python CLI tool built with Rust that finds all third-party packages imported into your Python project. Install Yo

Maksudul Haque 24 Feb 1, 2023
Rust-like syntax for OpenGL Shading Language

Rust-like syntax for GLSL glassful translates a small subset of Rust to OpenGL Shading Language. Besides one's personal preferences regarding Rust-lik

Keegan McAllister 158 Sep 22, 2022
Rust crate to create Anki decks. Based on the python library genanki

genanki-rs: A Rust Crate for Generating Anki Decks With genanki-rs you can easily generate decks for the popular open source flashcard platform Anki.

Yannick Funk 63 Dec 23, 2022
Robust and Fast tokenizations alignment library for Rust and Python

Robust and Fast tokenizations alignment library for Rust and Python

Yohei Tamura 14 Dec 10, 2022
A high performance python technical analysis library written in Rust and the Numpy C API.

Panther A efficient, high-performance python technical analysis library written in Rust using PyO3 and rust-numpy. Indicators ATR CMF SMA EMA RSI MACD

Greg 210 Dec 22, 2022
🌾 High-performance Text processing library for the Thai language, built with Rust and exposed as a Python package.

Thongna ?? Thongna (ท้องนา) is a high-performance text processing library for the Thai language, built with Rust and exposed as a Python package. Insp

fr4nk 3 Aug 17, 2024
Locality Sensitive Hashing in Rust with Python bindings

lsh-rs (Locality Sensitive Hashing) Locality sensitive hashing can help retrieving Approximate Nearest Neighbors in sub-linear time. For more informat

Ritchie Vink 65 Jan 2, 2023
Python package to compute levensthein distance in rust

Contents Introduction Installation Usage License Introduction Rust implementation of levensthein distance (https://en.wikipedia.org/wiki/Levenshtein_d

Thibault Blanc 2 Feb 21, 2022
Pyxirr - Rust-powered collection of financial functions for Python.

PyXIRR Rust-powered collection of financial functions. PyXIRR stands for "Python XIRR" (for historical reasons), but contains many other financial fun

Alexander Volkovsky 82 Jan 2, 2023
Rust-port of spotify/annoy as a wrapper for Approximate Nearest Neighbors in C++/Python optimized for memory usage.

Rust-port of spotify/annoy as a wrapper for Approximate Nearest Neighbors in C++/Python optimized for memory usage.

Arthur·Thomas 13 Mar 10, 2022
Rust-port of spotify/annoy as a wrapper for Approximate Nearest Neighbors in C++/Python optimized for memory usage.

Fareast This library is a rust port of spotify/annoy , currently only index serving is supported. It also provides FFI bindings for jvm, dotnet and da

Arthur·Thomas 13 Mar 10, 2022
Python+Rust implementation of the Probabilistic Principal Component Analysis model

Probabilistic Principal Component Analysis (PPCA) model This project implements a PPCA model implemented in Rust for Python using pyO3 and maturin. In

FindHotel 11 Dec 16, 2022
Low effort scraping Python's pickle format in Rust. It is to complete pickle parsing as BeautifulSoup was to complete HTML parsing.

repugnant-pickle Because it is, isn't it? This is a Rust crate for dealing with the Python pickle format. It also has support for opening PyTorch file

Kerfuffle 7 Apr 7, 2023
Sample Python extension using Rust/PyO3/tch to interact with PyTorch

Python extensions using tch to interact with PyTorch This sample crate shows how to use tch to write a Python extension that manipulates PyTorch tenso

Laurent Mazare 5 Jun 10, 2023
Rye is Armin's personal one-stop-shop for all his Python needs.

Rye Rye is Armin's personal one-stop-shop for all his Python needs. It installs and manages Python installations, manages pyproject.toml files, instal

Armin Ronacher 2.8k Apr 26, 2023
A Rust library with homemade machine learning models to classify the MNIST dataset. Built in an attempt to get familiar with advanced Rust concepts.

mnist-classifier Ideas UPDATED: Finish CLI Flags Parallelize conputationally intensive functions Class-based naive bayes README Image parsing Confusio

Neil Kaushikkar 0 Sep 2, 2021
Machine Learning library for Rust

rusty-machine This library is no longer actively maintained. The crate is currently on version 0.5.4. Read the API Documentation to learn more. And he

James Lucas 1.2k Dec 31, 2022
Rust library for Self Organising Maps (SOM).

RusticSOM Rust library for Self Organising Maps (SOM). Using this Crate Add rusticsom as a dependency in Cargo.toml [dependencies] rusticsom = "1.1.0"

Avinash Shenoy 26 Oct 17, 2022
A deep learning library for rust

Alumina An experimental deep learning library written in pure rust. Breakage expected on each release in the short term. See mnist.rs in examples or R

zza 95 Nov 30, 2022