Expand description
Hardware-friendly f32 mathematics for Rust no_std environments.
embedded-maths exposes scalar functions, vectors, matrices, quaternions,
statistics, and compile-time metadata without requiring micromath.
Implementations are delegated to focused crates when that provides better
accuracy, compatibility, or maintenance boundaries.
§Quick example
use embedded_maths::{asin, cos, hypot, sin, sqrt};
let angle = 0.5_f32;
assert!((sin(angle) - 0.479_425_55).abs() < 1e-6);
assert!((cos(angle) - 0.877_582_6).abs() < 1e-6);
assert!((asin(0.5) - core::f32::consts::FRAC_PI_6).abs() < 1e-6);
assert_eq!(hypot(3.0, 4.0), 5.0);
assert_eq!(sqrt(9.0).unwrap(), 3.0);§API groups
- [
sin], [cos], [tan], [sincos] - [
asin], [acos], [atan], [atan2] - [
sqrt], [invsqrt], [hypot] - [
exp], [ln], [log], [log2], [log10] - [
powf], [powi], [inv], [recip] - [
ceil], [floor], [round], [trunc], [fract] - [
abs], [signum], [copysign] mean,variance,std_dev,StreamingStatsVec2,Vec3,Vec4,QuaternionMatrix2x2,Matrix3x3
§Error behavior
Invalid-domain functions generally preserve the behavior documented in
their implementation crate: sqrt and invsqrt return Result; inverse
trigonometric functions return NaN outside their domain; infinities and
NaN values are handled explicitly where relevant.
§License
Licensed under GPL-2.0-or-later.
Re-exports§
pub use abs::abs;pub use acos::acos;pub use asin::asin;pub use atan::atan;pub use atan2::atan2;pub use ceil::ceil;pub use copysign::copysign;pub use cos::cos;pub use cosh::cosh;pub use div_euclid::div_euclid;pub use div_euclidean::div_euclid as div_euclidean;pub use exp::exp;pub use floor::floor;pub use fract::fract;pub use hypot::hypot;pub use inv::inv;pub use invsqrt::inv_sqrt as invsqrt;pub use ln::ln;pub use log::log;pub use log10::log10;pub use log2::log2;pub use mul_add::mul_add;pub use powf::powf;pub use powi::powi;pub use recip::recip;pub use rem_euclid::rem_euclid;pub use round::round;pub use signum::signum;pub use sin::sin;pub use sin_cos::sin_cos;pub use sqrt::sqrt;pub use tan::tan;pub use trunc::trunc;pub use statistics::mean;pub use statistics::variance;pub use statistics::std_dev;
Modules§
- abs
- Absolute value of
f32forno_std, withoutlibm. - acos
- Arc cosine of
f32forno_std, withoutlibm. - asin
- Arc sine of
f32forno_std, withoutlibm. - atan
- Arc tangent of
f32forno_std, withoutlibm. - atan2
- Four-quadrant arc tangent of
f32forno_std, withoutlibm. - ceil
f32ceiling operations.- copysign
f32sign-copy operations.- cos
- Cosinus pour
f32, sans dépendance externe. - cosh
- exp et cosh pour
f32, sans dépendance externe. - div_
euclid - Euclidean division for
f32. - div_
euclidean - Euclidean division alias.
- exp
- Exponential function
e^xforf32onno_stdembedded targets, powered byembedded-exp-f32. - floor
f32floor operations.- fract
f32fractional-part operations.- hypot
- Overflow-safe Euclidean norm for two
f32values. - inv
- Reciprocal operations for
f32. - invsqrt
- Fast inverse square root
1 / sqrt(x)forf32onno_stdembedded systems, powered byembedded-invsqrt-f32. - ln
- Logarithme népérien approché pour
f32, sans dépendance externe. - log
- log_b(x) approché pour
f32, sans dépendance externe. - log2
- log base 2 approché pour
f32, sans dépendance externe. - log10
- log base 10 approché pour
f32, sans dépendance externe. - matrix
- 2x2 and 3x3
f32matrices forno_stdembedded systems, powered byembedded-matrix. - mul_add
- Fused multiply-add operations for
f32. - powf
- Floating-point power for
f32. - powi
- x^n pour n entier (
powi), sans dépendance externe. - quaternion
- 4D quaternions and perspective projection (
f32,no_std), powered byembedded-quaternion-f32. - recip
- Reciprocal alias.
- rem_
euclid - Euclidean remainder for
f32. - round
f32rounding operations.- signum
- Signe d’un
f32, sans dépendance externe. - sin
- Sinus pour
f32, sans dépendance externe. - sin_cos
- sin, cos et sin_cos pour
f32, sans dépendance externe. - sqrt
- Square root of
f32forno_std, powered byembedded-f32-sqrt. - statistics
- Statistical analysis support for
f32onno_std, powered byembedded-stats-f32. - tan
- Tangente pour
f32, sans dépendance externe. - trunc
- Partie entière (troncature vers zéro) pour
f32, sans dépendance externe. - vector
- 2D, 3D, and 4D
f32vectors forno_stdembedded systems, powered byembedded-vector.
Structs§
- Matrix2x2
- A 2×2
f32matrix stored in row-major order. - Matrix3x3
- A 3×3
f32matrix stored in row-major order. - Quaternion
- Représente un quaternion q = w + xi + yj + z*k ou un point/vecteur dans l’espace 4D.
- Streaming
Stats - Accumulateur de moyenne en ligne, O(1) mémoire.
- Vec2
- A 2D vector of
f32components. - Vec3
- A 3D vector of
f32components. - Vec4
- A 4D vector of
f32components.
Enums§
- Matrix
Error - Error returned when a matrix operation is invalid.
- Stats
Error - Erreurs EmptySlice et NonFiniteValue pour la roboustesse du systeme
- VecError
- Errors returned by vector operations.
Functions§
- kahan_
mean - Calcule la moyenne arithmétique d’une tranche
f32. - kahan_
std_ dev - Calcule l’écart type de population (= √variance) d’une tranche
f32. - kahan_
variance - Calcule la variance de population (non corrigée, diviseur N) d’une tranche
f32.