Skip to main content

Module constants

Module constants 

Source
Expand description

§constants

A collection of f64 constants commonly used in mathematics, physics, electromagnetics, signal processing, and machine learning.

§Layout

ModuleContents
mathPi, e, golden ratio, Euler–Mascheroni, Apéry, Catalan, …
physicsCODATA fundamental constants, thermodynamics, astronomy
emVacuum permeability/permittivity, impedances, quantum EM units
dspdB conversions, window coefficients, audio, noise, quantization
mlActivation constants, optimizer defaults, dataset statistics
unitsAngle, length, mass, pressure, energy conversion factors

§Sources and conventions

  • Physical constants follow CODATA 2022 (SI 2019 redefinition). Values that are exact by definition (C, H, K_B, N_A, E_CHARGE) are exact; measured values carry their CODATA uncertainty in the final digits.
  • Where a constant is algebraically derived from others (e.g. HBAR, R_GAS, MU_B) it is computed at compile time from its definition so that the set stays self-consistent.
  • All values are SI unless the name says otherwise (_EV, _DEG, _HZ…).
  • Works in #![no_std] contexts: only core is used.

§Usage

ⓘ
mod constants;
use constants::{em, physics, math};

let wavelength = physics::C / 2.4e9;
let z0 = em::Z_0;
let tau = math::TAU;

See the book entry Shared types, constants and utilities.

Modules§

dsp
Constants for DSP, audio, and RF noise/link-budget calculations.
em
Electromagnetic constants and typical material properties.
math
Mathematical constants.
ml
Constants and default hyper-parameters common in machine learning.
physics
Fundamental and derived physical constants (SI units, CODATA 2022).
units
Conversion factors to SI. Multiply a value in the named unit by the constant to obtain the SI value (e.g. 5.0 * INCH → metres).