Skip to main content

numra_core/
lib.rs

1//! # Numra Core
2//!
3//! Core traits and types for the Numra numerical methods library.
4//!
5//! This crate provides the fundamental abstractions that all other Numra crates build upon:
6//!
7//! - [`Scalar`] - Trait for scalar numeric types (f32, f64)
8//! - [`Vector`] - Trait for vector types
9//! - [`Signal`] - Trait for time-dependent forcing functions
10//! - Error types and result definitions
11//!
12//! ## Design Philosophy
13//!
14//! Numra Core is designed to be:
15//! - **Backend-agnostic**: Works with faer, nalgebra, or pure Rust
16//! - **No-std compatible**: Can be used in embedded systems (with alloc)
17//! - **Zero-cost abstractions**: Compiles to optimal machine code
18//!
19//! ## Example
20//!
21//! ```rust
22//! use numra_core::{Scalar, Signal};
23//! use numra_core::signal::Harmonic;
24//!
25//! // Define a harmonic forcing function
26//! let forcing = Harmonic::new(1.0, 2.0, 0.0);  // amplitude=1, freq=2 Hz, phase=0
27//!
28//! // Evaluate at t=0.25s (should be sin(2π*2*0.25) = sin(π) = 0)
29//! let value = forcing.eval(0.25);
30//! assert!(value.abs() < 1e-10);
31//! ```
32//!
33//! Author: Moussa Leblouba
34//! Date: 9 February 2026
35//! Modified: 2 May 2026
36
37#![cfg_attr(not(feature = "std"), no_std)]
38
39#[cfg(not(feature = "std"))]
40extern crate alloc;
41
42pub mod error;
43pub mod scalar;
44pub mod signal;
45pub mod uncertainty;
46pub mod vector;
47
48pub use error::{LinalgError, NumraError, NumraResult};
49pub use scalar::{from_f64_vec, to_f64_vec, Scalar};
50pub use signal::Signal;
51pub use uncertainty::{
52    compute_sensitivities, Interval, ParameterSensitivity, ParameterSensitivityResult, Uncertain,
53};
54pub use vector::Vector;
55
56/// Commonly used items
57pub mod prelude {
58    pub use crate::error::{NumraError, NumraResult};
59    #[cfg(feature = "std")]
60    pub use crate::signal::FromFile;
61    pub use crate::signal::{Chirp, Harmonic, Interpolation, Pulse, Ramp, Step, Tabulated};
62    pub use crate::uncertainty::{Interval, Uncertain};
63    pub use crate::Scalar;
64    pub use crate::Signal;
65    pub use crate::Vector;
66}