cheby 0.1.0

Chebyshev polynomial toolkit: node generation, coefficient fitting (DCT), and Clenshaw evaluation — generic over scalar type.
Documentation
  • Coverage
  • 100%
    34 out of 34 items documented4 out of 25 items with examples
  • Size
  • Source code size: 80.7 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.75 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 49s Average build duration of successful builds.
  • all releases: 49s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Siderust/cheby
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • VPRamon

cheby

Chebyshev polynomial toolkit for scientific computing in Rust.

cheby provides a full interpolation pipeline suitable for numerical kernels and ephemeris-style piecewise approximations:

  1. Node generation on [-1, 1] and mapped intervals.
  2. Coefficient fitting via DCT identities.
  3. Stable Clenshaw evaluation (value, derivative, or both).
  4. Uniform piecewise segment tables with O(1) segment lookup.

All core APIs are generic over ChebyScalar, so they work with f64 and with typed quantities such as qtty::Quantity<Kilometer>.

Installation

[dependencies]
cheby = "0.1"

Quick start

use cheby::{evaluate, fit_coeffs, nodes};

const N: usize = 9;
let xi: [f64; N] = nodes();
let values: [f64; N] = std::array::from_fn(|k| xi[k].sin());
let coeffs = fit_coeffs(&values);

let tau = 0.42;
let approx = evaluate(&coeffs, tau);
println!("sin({tau}) ~= {approx}");

Segment-table workflow

use cheby::ChebySegmentTable;

let table: ChebySegmentTable<f64, 15> =
    ChebySegmentTable::from_fn(f64::sin, 0.0, std::f64::consts::TAU, std::f64::consts::FRAC_PI_2);

let (value, derivative) = table.eval_both(1.0).unwrap();
println!("f(t)={value}, df/dt={derivative}");

Examples

Runnable examples are provided in examples/:

  • basic_interpolation
  • segment_table
  • typed_quantities

Use:

cargo run --example basic_interpolation

See examples/README.md for details.

Tests and coverage

cheby includes:

  • Unit tests inside modules.
  • Functional integration tests in tests/functional_pipeline.rs.
  • Doctests for public examples.

Run locally:

cargo test --all-targets
cargo test --doc
cargo +nightly llvm-cov --workspace --all-features --doctests --summary-only

Coverage is gated in CI at >= 90% line coverage.

CI

GitHub Actions workflow: /.github/workflows/ci.yml

Jobs:

  • check
  • fmt
  • clippy (-D warnings)
  • test (unit/integration + docs)
  • coverage (cargo +nightly llvm-cov, PR summary, 90% gate)

License

AGPL-3.0-only