Rust API¶
The pure-Rust crate lineshapes has no Python dependency. Build the same model, with the same parameter
vector and evaluator:
use lineshapes::{Evaluator, Model};
let mut m = Model::new()
.gaussian(933.8, 0.49, 4.1e-5) // e0, 1/e half-width, beta height
.voigt(938.3, 0.7, 0.2, 5e-5) // e0, sigma, gamma (HWHM), height
.continuum(3.6e-4, -3.7e-7)
.step(939.4, 6.1, 7.2e-5, 0.0);
let n = m.eval(&energies); // Vec<Complex64>, single core
let n = m.eval_par(&energies); // feature "parallel" (default): rayon
let mut theta = m.params(); // flat parameter vector
theta[0] += 0.01;
m.set_params(&theta)?;
let mut ev = Evaluator::new(m, &energies, true); // bound grid + per-component cache
ev.eval_params_into(&theta, &mut out)?;
Types: Model, Component (the natural parameters of each lineshape) and Evaluator. Constructors panic on
invalid parameters; Model::try_add and set_params return a Result instead.
The full API documentation is generated by rustdoc: run cargo doc -p lineshapes --open. Once the crate is
published it is on docs.rs/lineshapes.