Skip to main content

rustkernel_temporal/
lib.rs

1//! # RustKernel Temporal Analysis
2//!
3//! GPU-accelerated temporal analysis kernels for forecasting, decomposition,
4//! detection, and volatility modeling.
5//!
6//! ## Kernels
7//!
8//! ### Forecasting (2 kernels)
9//! - `ARIMAForecast` - ARIMA(p,d,q) model fitting and forecasting
10//! - `ProphetDecomposition` - Prophet-style trend/seasonal/holiday decomposition
11//!
12//! ### Detection (2 kernels)
13//! - `ChangePointDetection` - PELT/Binary segmentation/CUSUM
14//! - `TimeSeriesAnomalyDetection` - Statistical threshold detection
15//!
16//! ### Decomposition (2 kernels)
17//! - `SeasonalDecomposition` - STL-style decomposition
18//! - `TrendExtraction` - Moving average variants
19//!
20//! ### Analysis (1 kernel)
21//! - `VolatilityAnalysis` - GARCH model volatility estimation
22
23#![warn(missing_docs)]
24
25pub mod decomposition;
26pub mod detection;
27pub mod forecasting;
28pub mod messages;
29pub mod ring_messages;
30pub mod types;
31pub mod volatility;
32
33/// Prelude for convenient imports.
34pub mod prelude {
35    pub use crate::decomposition::*;
36    pub use crate::detection::*;
37    pub use crate::forecasting::*;
38    pub use crate::messages::*;
39    pub use crate::ring_messages::*;
40    pub use crate::types::*;
41    pub use crate::volatility::*;
42}
43
44// Re-export main kernels
45pub use decomposition::{SeasonalDecomposition, TrendExtraction};
46pub use detection::{ChangePointDetection, TimeSeriesAnomalyDetection};
47pub use forecasting::{ARIMAForecast, ProphetDecomposition};
48pub use volatility::VolatilityAnalysis;
49
50// Re-export key types
51pub use types::{
52    ARIMAParams, ARIMAResult, AnomalyMethod, ChangePointMethod, ChangePointResult,
53    DecompositionResult, GARCHCoefficients, GARCHParams, ProphetResult, TimeSeries,
54    TimeSeriesAnomalyResult, TrendMethod, TrendResult, VolatilityResult,
55};
56
57/// Register all temporal kernels with a registry.
58pub fn register_all(
59    registry: &rustkernel_core::registry::KernelRegistry,
60) -> rustkernel_core::error::Result<()> {
61    tracing::info!("Registering temporal analysis kernels");
62
63    // Forecasting kernels (2) - Batch
64    registry.register_batch_typed(forecasting::ARIMAForecast::new)?;
65    registry.register_batch_typed(forecasting::ProphetDecomposition::new)?;
66
67    // Detection kernels (2)
68    registry.register_batch_typed(detection::ChangePointDetection::new)?; // Batch
69    registry.register_ring_metadata_from(detection::TimeSeriesAnomalyDetection::new)?; // Ring
70
71    // Decomposition kernels (2) - Batch
72    registry.register_batch_typed(decomposition::SeasonalDecomposition::new)?;
73    registry.register_batch_typed(decomposition::TrendExtraction::new)?;
74
75    // Volatility kernel (1) - Ring
76    registry.register_ring_metadata_from(volatility::VolatilityAnalysis::new)?;
77
78    tracing::info!("Registered 7 temporal analysis kernels");
79    Ok(())
80}
81
82#[cfg(test)]
83mod tests {
84    use super::*;
85    use rustkernel_core::registry::KernelRegistry;
86
87    #[test]
88    fn test_register_all() {
89        let registry = KernelRegistry::new();
90        register_all(&registry).expect("Failed to register temporal kernels");
91        assert_eq!(registry.total_count(), 7);
92    }
93}