numerics-rs 0.1.0

Blazing fast numerical library written in pure Rust
Documentation
  • Coverage
  • 26.67%
    4 out of 15 items documented0 out of 5 items with examples
  • Size
  • Source code size: 43.17 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 594.17 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • grmikh/numerics-rs
    0 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • grmikh

numerics-rs

Crates.io Docs.rs CI

About

In order to learn Rust, I decided to create a project inspired by the most common problems I have encountered working in finanial engineering. It is written in pure Rust and I strive for it to be the fastest existing implementation. Currently supports:

  • Interpolation (Univariate, spline polynomials up to an order of 3)
  • Numerical solving (WIP)
  • Convenient matrix API and common matrix operations (WIP)

Usage

To use, add this to your crate:

use numerics_rs::interp::{InterpolationType, Interpolator, ExtrapolationStrategy};

fn main() {
    // ...
}

Examples

Linear interpolation:

        let x_values = vec![0.0, 1.0, 2.0, 3.0];
        let y_values = vec![0.0, 2.0, 4.0, 6.0];

        // Create an interpolator
        let interpolator = Interpolator::new(x_values, y_values, InterpolationType::Linear, ExtrapolationStrategy::None);

        // Test linear interpolation at known points
        assert_eq!(interpolator.interpolate(0.0), 0.0);
        assert_eq!(interpolator.interpolate(1.0), 2.0);
        assert_eq!(interpolator.interpolate(2.0), 4.0);
        assert_eq!(interpolator.interpolate(3.0), 6.0);

        // Test linear interpolation between the points
        assert_eq!(interpolator.interpolate(0.5), 1.0);
        assert_eq!(interpolator.interpolate(1.5), 3.0);
        assert_eq!(interpolator.interpolate(2.5), 5.0);

Dependencies

It comes with 0 external dependencies

Thread safety

Everything in the API is immutable, thus it is safe to use in a multi-threaded environment

How fast is it?

It is very fast and lightweight, it is using precomputed coefficients and it scales really well if you want to call it many times using the same set of knots. Benchmarks will be added in future versions

Cargo

  • Install the rust toolchain in order to have cargo installed by following this guide.
  • run cargo install numerics-rs

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

See CONTRIBUTING.md.

Feedback

This is my first Rust project therefore I greatly appreciate your feedback, feel free to get in touch