Skip to main content

scirs2_stats/adaptive_memory_advanced/
functions.rs

1//! Auto-generated module
2//!
3//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
4
5use scirs2_core::numeric::{Float, NumCast, One, Zero};
6use scirs2_core::{
7    parallel_ops::*,
8    simd_ops::{PlatformCapabilities, SimdUnifiedOps},
9};
10
11use super::types::{AdaptiveMemoryConfig, AdaptiveMemoryManager, TrainingExample};
12
13/// Predictive model trait
14pub trait PredictiveModel: Send + Sync {
15    fn predict(&self, features: &[f64]) -> f64;
16    fn train(&mut self, trainingdata: &[TrainingExample]) -> Result<(), String>;
17    fn get_confidence(&self) -> f64;
18    fn get_feature_importance(&self) -> Vec<f64>;
19}
20/// Compressor trait
21pub trait Compressor: Send + Sync {
22    fn compress(&self, data: &[u8]) -> Result<Vec<u8>, String>;
23    fn decompress(&self, data: &[u8]) -> Result<Vec<u8>, String>;
24    fn compression_ratio(&self, originalsize: usize, compressedsize: usize) -> f64;
25}
26/// Convenient type aliases
27pub type F64AdaptiveMemoryManager = AdaptiveMemoryManager<f64>;
28pub type F32AdaptiveMemoryManager = AdaptiveMemoryManager<f32>;
29/// Factory functions
30#[allow(dead_code)]
31pub fn create_adaptive_memory_manager<F>() -> AdaptiveMemoryManager<F>
32where
33    F: Float
34        + NumCast
35        + SimdUnifiedOps
36        + Zero
37        + One
38        + PartialOrd
39        + Copy
40        + Send
41        + Sync
42        + 'static
43        + std::fmt::Display,
44{
45    AdaptiveMemoryManager::new()
46}
47#[allow(dead_code)]
48pub fn create_optimized_memory_manager<F>(config: AdaptiveMemoryConfig) -> AdaptiveMemoryManager<F>
49where
50    F: Float
51        + NumCast
52        + SimdUnifiedOps
53        + Zero
54        + One
55        + PartialOrd
56        + Copy
57        + Send
58        + Sync
59        + 'static
60        + std::fmt::Display,
61{
62    AdaptiveMemoryManager::with_config(config)
63}