Crates.io | curve-sampling |
lib.rs | curve-sampling |
version | 0.4.0 |
source | src |
created_at | 2022-08-27 12:56:26.001466 |
updated_at | 2024-01-03 21:35:19.552623 |
description | Adaptive sampling of parametric |
homepage | |
repository | https://github.com/Chris00/rust-curve-sampling |
max_upload_size | |
id | 653410 |
size | 162,695 |
This module provide a collection of routines to perform adaptive sampling of curves as well as manipulating those samplings.
Add this to your Cargo.toml
:
[dependencies]
curve-sampling = "0.4"
See the documentation.
To sample the function x ↦ x sin(1/x) on the interval [-0.4, 0.4] with 227 function evaluations, simply do
use curve_sampling::Sampling;
let s = Sampling::fun(|x| x * (1. / x).sin(), -0.4, 0.4).n(227).build();
You can save the resulting sampling to TikZ with
s.latex().write(&mut File::create("graph.tex")?)?;
or to a data file (whose format is compatible with Gnuplot) with
s.write(&mut File::create("graph.dat")?)?;
Asking Gnuplot to draw the resulting curve (with plot 'graph.dat'
)
yields:
P.S. The number of evaluations (227) was chosen to match a depth 5 recursion for Mathematica.