Skip to main content

fixed_analytics/
lib.rs

1//! Fixed-point math via CORDIC. No floating-point ops, `no_std` compatible.
2//!
3//! # Quick Start
4//!
5//! ```rust
6//! use fixed::types::I16F16;
7//! use fixed_analytics::{sin, cos, sqrt, ln};
8//!
9//! let angle = I16F16::from_num(0.5);
10//! let (s, c) = (sin(angle), cos(angle));
11//! let root = sqrt(I16F16::from_num(2.0)).unwrap();
12//! let log = ln(I16F16::E).unwrap();
13//! ```
14//!
15//! # Precision
16//!
17//! | Type | Accuracy |
18//! |------|----------|
19//! | `I16F16` | ~4 decimal digits |
20//! | `I32F32` | ~8 decimal digits |
21//!
22//! # Features
23//!
24//! - `std` (default): Enables `std::error::Error` impl
25//!
26//! See [`kernel`] module for algorithm details.
27
28#![no_std]
29#![cfg_attr(docsrs, feature(doc_cfg))]
30
31pub mod bounded;
32pub mod error;
33pub mod kernel;
34pub mod ops;
35pub mod tables;
36pub mod traits;
37
38// Re-export the fixed crate for convenience
39pub use fixed;
40
41// Re-export main types
42pub use error::{Error, Result};
43pub use traits::CordicNumber;
44
45// Re-export all mathematical functions at crate root for convenience
46pub use ops::algebraic::sqrt;
47pub use ops::circular::{acos, asin, atan, atan2, cos, sin, sin_cos, tan};
48pub use ops::exponential::{exp, ln, log2, log10, pow2};
49pub use ops::hyperbolic::{acosh, acoth, asinh, atanh, cosh, coth, sinh, sinh_cosh, tanh};