nikisas_test

Crates.ionikisas_test
lib.rsnikisas_test
version0.1.0
sourcesrc
created_at2020-09-25 15:16:25.327907
updated_at2020-09-25 15:16:25.327907
descriptionUtilities for testing implementation quality of mathematical functions. Computing errors for inputs randomly sampled from given interval.
homepagehttps://crates.io/crates/nikisas_test
repositoryhttps://github.com/pnevyk/nikisas_test
max_upload_size
id292859
size34,127
Petr Nevyhoštěný (pnevyk)

documentation

https://crates.io/crates/nikisas_test

README

nikisas_test

Utilities for testing implementation quality of mathematical functions. Computing errors for inputs randomly sampled from given interval.

Usage

To determine the errors:

use nikisas_test::prelude::*;

fn exp(x: f32) -> f32 {
    // your implementation
    # 0.0
}

// Uniformly sample 100000 values from -87.3 to 88.7.
UniformSample::with_count(-87.3, 88.7, 100000)
    // Use implementation from the standard library as ground truth.
    .error(|x| (exp(x), x.exp()))
    // Print the errors to standard output.
    .print_plain("exp");

To ensure desired error bounds:

use nikisas_test::prelude::*;

// Uniformly sample 100000 values from -87.3 to 88.7.
UniformSample::with_count(-87.3, 88.7, 100000)
    // Use implementation from the standard library as ground truth.
    // If eny specified error bound is violated, the program panics with a readable message.
    .assert(ErrorBounds::new().rel(0.001).abs(0.0001), |x| (exp(x), x.exp()));

Documentation

See documentation on crates.io.

License

nikisas_test is licensed under MIT. Feel free to use it, contribute or spread the word.

Commit count: 0

cargo fmt