scirs2_core/
lib.rs

1#![recursion_limit = "512"]
2// TODO: Address deprecated code usage and remove this allow
3#![allow(deprecated)]
4// TODO: Remove dead code or justify why it's kept
5#![allow(dead_code)]
6// Clippy allow attributes for non-critical warnings
7#![allow(clippy::empty_line_after_outer_attribute)]
8#![allow(clippy::empty_line_after_doc_comments)]
9#![allow(clippy::manual_clamp)]
10#![allow(clippy::redundant_closure)]
11#![allow(clippy::useless_format)]
12#![allow(clippy::result_large_err)]
13#![allow(clippy::manual_is_multiple_of)]
14#![allow(clippy::manual_div_ceil)]
15#![allow(clippy::enumerate_and_ignore)]
16#![allow(clippy::redundant_pattern_matching)]
17#![allow(clippy::or_fun_call)]
18#![allow(clippy::unnecessary_lazy_evaluations)]
19#![allow(clippy::needless_borrow)]
20#![allow(clippy::derivable_impls)]
21#![allow(clippy::new_without_default)]
22#![allow(clippy::ptr_arg)]
23#![allow(clippy::get_first)]
24#![allow(clippy::needless_range_loop)]
25#![allow(clippy::type_complexity)]
26#![allow(clippy::assertions_on_constants)]
27#![allow(clippy::needless_return)]
28#![allow(clippy::unnecessary_cast)]
29#![allow(clippy::manual_range_contains)]
30#![allow(clippy::empty_line_after_outer_attribute_doc)]
31#![allow(clippy::upper_case_acronyms)]
32#![allow(clippy::excessive_precision)]
33#![allow(clippy::needless_borrows_for_generic_args)]
34#![allow(clippy::empty_line_after_outer_attr)]
35#![allow(clippy::unused_enumerate_index)]
36#![allow(clippy::unwrap_or_default)]
37
38//! # SciRS2 Core - Foundation for Scientific Computing in Rust
39//!
40//! **scirs2-core** is the foundational crate for the SciRS2 scientific computing ecosystem,
41//! providing essential utilities, abstractions, and optimizations used by all SciRS2 modules.
42//!
43//! ## 🎯 Design Philosophy
44//!
45//! - **Zero-Cost Abstractions**: Performance without compromising safety
46//! - **Layered Architecture**: Clear separation between interface and implementation
47//! - **Policy Compliance**: Enforce [SciRS2 POLICY](https://github.com/cool-japan/scirs/blob/master/SCIRS2_POLICY.md) - only scirs2-core uses external dependencies directly
48//! - **Production Ready**: Enterprise-grade error handling, diagnostics, and stability guarantees
49//!
50//! ## 🚀 Key Features
51//!
52//! ### Performance Acceleration
53//!
54//! - **SIMD Operations**: CPU vector instructions (SSE, AVX, NEON) for array operations
55//! - **Parallel Processing**: Multi-threaded execution with intelligent load balancing
56//! - **GPU Acceleration**: Unified interface for CUDA, Metal, OpenCL, and WebGPU
57//! - **Memory Efficiency**: Zero-copy views, memory-mapped arrays, adaptive chunking
58//!
59//! ### Core Utilities
60//!
61//! - **Error Handling**: ML-inspired diagnostics with recovery strategies
62//! - **Validation**: Input checking with informative error messages
63//! - **Caching**: Memoization and result caching for expensive computations
64//! - **Profiling**: Performance monitoring and bottleneck detection
65//!
66//! ### Scientific Infrastructure
67//!
68//! - **Constants**: Physical and mathematical constants (via [`constants`] module)
69//! - **Random Number Generation**: Consistent RNG interface across the ecosystem
70//! - **Complex Numbers**: Type-safe complex arithmetic
71//! - **Array Protocol**: Unified array interface for interoperability
72//!
73//! ## 📦 Module Overview
74//!
75//! ### Performance & Optimization
76//!
77//! | Module | Description |
78//! |--------|-------------|
79//! | [`simd_ops`] | SIMD-accelerated operations with platform detection |
80//! | [`parallel_ops`] | Parallel processing primitives |
81//! | [`gpu`] | GPU acceleration abstractions |
82//! | [`memory`] | Memory management (buffer pools, zero-copy views) |
83//! | [`memory_efficient`] | Memory-mapped arrays and lazy evaluation |
84//!
85//! ### Error Handling & Diagnostics
86//!
87//! | Module | Description |
88//! |--------|-------------|
89//! | [`error`] | Error types and traits |
90//! | [`validation`] | Input validation utilities |
91//! | [`logging`] | Structured logging for diagnostics |
92//! | [`profiling`] | Performance profiling tools |
93//!
94//! ### Scientific Computing Basics
95//!
96//! | Module | Description |
97//! |--------|-------------|
98//! | [`ndarray`] | Unified ndarray interface (re-exports with SciRS2 extensions) |
99//! | [`numeric`] | Generic numerical operations |
100//! | [`random`] | Random number generation |
101//! | [`constants`] | Mathematical and physical constants |
102//!
103//! ### Infrastructure
104//!
105//! | Module | Description |
106//! |--------|-------------|
107//! | [`config`] | Configuration management |
108//! | [`cache`] | Result caching and memoization |
109//! | [`io`] | I/O utilities |
110//! | [`cloud`] | Cloud storage integration (S3, GCS, Azure) |
111//!
112//! ## 🚀 Quick Start
113//!
114//! ### Installation
115//!
116//! ```toml
117//! [dependencies]
118//! scirs2-core = { version = "0.1.0-rc.2", features = ["simd", "parallel"] }
119//! ```
120//!
121//! ### SIMD Operations
122//!
123//! ```rust
124//! use scirs2_core::simd_ops::SimdUnifiedOps;
125//! use ndarray::array;
126//!
127//! // Automatic SIMD acceleration based on CPU capabilities
128//! let a = array![1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0];
129//! let b = array![8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0];
130//!
131//! // SIMD-accelerated element-wise addition
132//! let result = f64::simd_add(&a.view(), &b.view());
133//! ```
134//!
135//! ### Parallel Processing
136//!
137//! ```rust
138//! # #[cfg(feature = "parallel")]
139//! # {
140//! use scirs2_core::parallel_ops::*;
141//!
142//! // Parallel iteration over chunks
143//! let data = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
144//! par_chunks(&data, 3).for_each(|chunk| {
145//!     // Process each chunk in parallel
146//!     let sum: i32 = chunk.iter().sum();
147//!     println!("Chunk sum: {}", sum);
148//! });
149//! # }
150//! ```
151//!
152//! ### Input Validation
153//!
154//! ```rust
155//! use scirs2_core::validation::*;
156//! use scirs2_core::error::CoreResult;
157//! use ndarray::Array2;
158//!
159//! fn process_matrix(data: &Array2<f64>, k: usize) -> CoreResult<()> {
160//!     // Validate inputs
161//!     check_positive(k, "k")?;
162//!     checkarray_finite(data, "data")?;
163//!     checkshape(data, &[2, 3], "data")?;
164//!
165//!     // Process data...
166//!     Ok(())
167//! }
168//! # let data = Array2::<f64>::zeros((2, 3));
169//! # let _ = process_matrix(&data, 5);
170//! ```
171//!
172//! ### Constants
173//!
174//! ```rust
175//! use scirs2_core::constants::{math, physical};
176//!
177//! // Mathematical constants
178//! let pi = math::PI;
179//! let e = math::E;
180//!
181//! // Physical constants
182//! let c = physical::SPEED_OF_LIGHT;
183//! let h = physical::PLANCK;
184//! ```
185//!
186//! ### Random Number Generation
187//!
188//! ```rust
189//! # #[cfg(feature = "random")]
190//! # {
191//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
192//! use scirs2_core::random::*;
193//! use rand::Rng;
194//!
195//! // Standard distributions
196//! let mut rng = rand::rng();
197//! let normal = Normal::new(0.0, 1.0)?;
198//! let samples: Vec<f64> = (0..1000).map(|_| normal.sample(&mut rng)).collect();
199//!
200//! let uniform = Uniform::new(0.0, 1.0)?;
201//! let samples: Vec<f64> = (0..1000).map(|_| uniform.sample(&mut rng)).collect();
202//! # Ok(())
203//! # }
204//! # }
205//! ```
206//!
207//! ### Memory-Efficient Operations
208//!
209//! ```rust,no_run
210//! # #[cfg(feature = "memory_efficient")]
211//! # {
212//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
213//! use scirs2_core::memory_efficient::*;
214//! use std::path::Path;
215//! use ndarray::Array2;
216//!
217//! // Memory-mapped array for large datasets
218//! let data = Array2::<f64>::zeros((1000, 1000));
219//! let path = Path::new("/path/to/large_file.dat");
220//! let mmap = create_mmap(&data, path, AccessMode::ReadWrite, 0)?;
221//!
222//! // Chunked operations for out-of-core processing
223//! let result = chunk_wise_op(&data, |chunk| {
224//!     chunk.mapv(|x| x * 2.0)
225//! }, ChunkingStrategy::Fixed(10000))?;
226//! # Ok(())
227//! # }
228//! # }
229//! ```
230//!
231//! ## 🏗️ Architecture
232//!
233//! ```text
234//! ┌─────────────────────────────────────────┐
235//! │     SciRS2 Ecosystem Modules            │
236//! │  (linalg, stats, neural, vision, etc.)  │
237//! └─────────────────────────────────────────┘
238//!              ▼
239//! ┌─────────────────────────────────────────┐
240//! │         scirs2-core (This Crate)        │
241//! │  ┌────────────────────────────────────┐ │
242//! │  │  High-Level Abstractions           │ │
243//! │  │  - SIMD Operations                 │ │
244//! │  │  - Parallel Processing             │ │
245//! │  │  - GPU Acceleration                │ │
246//! │  │  - Error Handling                  │ │
247//! │  └────────────────────────────────────┘ │
248//! │  ┌────────────────────────────────────┐ │
249//! │  │  Core Utilities                    │ │
250//! │  │  - Array Protocol                  │ │
251//! │  │  - Validation                      │ │
252//! │  │  - Memory Management               │ │
253//! │  │  - Configuration                   │ │
254//! │  └────────────────────────────────────┘ │
255//! └─────────────────────────────────────────┘
256//!              ▼
257//! ┌─────────────────────────────────────────┐
258//! │     External Dependencies               │
259//! │  (ndarray, rayon, BLAS, etc.)           │
260//! │  ⚠️  Only scirs2-core depends directly  │
261//! └─────────────────────────────────────────┘
262//! ```
263//!
264//! ## 🎨 Feature Flags
265//!
266//! ### Performance Features
267//!
268//! - `simd` - SIMD acceleration (SSE, AVX, NEON)
269//! - `parallel` - Multi-threaded execution via Rayon
270//! - `gpu` - GPU acceleration (CUDA, Metal, OpenCL)
271//!
272//! ### Memory Management
273//!
274//! - `memory_management` - Advanced memory management (buffer pools, tracking)
275//! - `memory_efficient` - Memory-mapped arrays and lazy evaluation
276//! - `memory_metrics` - Memory usage tracking and profiling
277//!
278//! ### Scientific Computing
279//!
280//! - `array` - Scientific array types (MaskedArray, RecordArray)
281//! - `random` - Random number generation
282//! - `linalg` - Linear algebra with BLAS/LAPACK
283//!
284//! ### Development & Debugging
285//!
286//! - `validation` - Input validation (recommended for development)
287//! - `logging` - Structured logging
288//! - `profiling` - Performance profiling
289//! - `testing` - Testing utilities
290//!
291//! ### Advanced Features
292//!
293//! - `cloud` - Cloud storage (S3, GCS, Azure)
294//! - `jit` - Just-in-time compilation with LLVM
295//! - `ml_pipeline` - ML pipeline integration
296//!
297//! ### Convenience
298//!
299//! - `default` - Commonly used features (parallel, validation)
300//! - `all` - All features except backend-specific ones
301//!
302//! ## 🔒 SciRS2 Policy Compliance
303//!
304//! **Important**: scirs2-core is the **only** crate in the SciRS2 ecosystem that directly
305//! depends on external crates like `ndarray`, `rand`, `rayon`, etc.
306//!
307//! All other SciRS2 crates **must** use abstractions provided by scirs2-core:
308//!
309//! ```rust,ignore
310//! // ✅ CORRECT: Use scirs2-core abstractions
311//! use scirs2_core::ndarray::Array2;
312//! use scirs2_core::random::Normal;
313//! use scirs2_core::parallel_ops::*;
314//!
315//! // ❌ WRONG: Don't import external deps directly in other crates
316//! // use ndarray::Array2;       // NO!
317//! // use rand_distr::Normal;    // NO!
318//! // use rayon::prelude::*;     // NO!
319//! ```
320//!
321//! This policy ensures:
322//! - Consistent APIs across the ecosystem
323//! - Centralized version management
324//! - Easy addition of SciRS2-specific extensions
325//! - Better compile times through reduced duplication
326//!
327//! ## 📊 Performance
328//!
329//! scirs2-core provides multiple optimization levels:
330//!
331//! | Feature | Speedup | Use Case |
332//! |---------|---------|----------|
333//! | SIMD | 2-8x | Array operations, numerical computations |
334//! | Parallel | 2-16x | Large datasets, independent operations |
335//! | GPU | 10-100x | Massive parallelism, deep learning |
336//! | Memory-mapped | ∞ | Out-of-core processing, datasets larger than RAM |
337//!
338//! ### Platform Detection
339//!
340//! Automatic CPU feature detection for optimal SIMD usage:
341//!
342//! ```rust
343//! use scirs2_core::simd_ops::PlatformCapabilities;
344//!
345//! let caps = PlatformCapabilities::detect();
346//! println!("SIMD available: {}", caps.simd_available);
347//! println!("AVX2 available: {}", caps.avx2_available);
348//! println!("GPU available: {}", caps.gpu_available);
349//! ```
350//!
351//! ## 🔗 Integration
352//!
353//! scirs2-core integrates seamlessly with the Rust ecosystem:
354//!
355//! - **ndarray**: Core array operations
356//! - **num-traits**: Generic numeric operations
357//! - **rayon**: Parallel processing
358//! - **BLAS/LAPACK**: Optimized linear algebra
359//!
360//! ## 🔒 Version
361//!
362//! Current version: **0.1.0-rc.2** (Released October 19, 2025)
363//!
364//! ## 📚 Examples
365//!
366//! See the [examples directory](https://github.com/cool-japan/scirs/tree/master/scirs2-core/examples)
367//! for more detailed usage examples.
368
369// Re-export modules
370pub mod api_freeze;
371pub mod apiversioning;
372#[cfg(feature = "array")]
373pub mod array;
374pub mod array_protocol;
375#[cfg(feature = "types")]
376pub mod batch_conversions;
377#[cfg(feature = "cache")]
378pub mod cache;
379pub mod chunking;
380#[cfg(feature = "cloud")]
381pub mod cloud;
382pub mod config;
383pub mod constants;
384pub mod distributed;
385pub mod ecosystem;
386pub mod error;
387#[cfg(feature = "gpu")]
388pub mod gpu;
389#[cfg(feature = "gpu")]
390pub mod gpu_registry;
391pub mod io;
392#[cfg(feature = "jit")]
393pub mod jit;
394#[cfg(feature = "logging")]
395pub mod logging;
396#[cfg(feature = "memory_management")]
397pub mod memory;
398#[cfg(feature = "memory_efficient")]
399pub mod memory_efficient;
400pub mod metrics;
401#[cfg(feature = "ml_pipeline")]
402pub mod ml_pipeline;
403pub mod ndarray;
404pub mod ndarray_ext;
405pub mod numeric;
406#[cfg(feature = "parallel")]
407pub mod parallel;
408#[cfg(feature = "parallel")]
409pub mod parallel_ops;
410pub mod performance;
411pub mod performance_optimization;
412#[cfg(feature = "profiling")]
413pub mod profiling;
414#[cfg(feature = "random")]
415pub mod random;
416pub mod resource;
417#[cfg(feature = "simd")]
418pub mod simd;
419pub mod simd_aligned;
420pub mod simd_ops;
421#[cfg(feature = "testing")]
422pub mod testing;
423// Universal Functions (ufuncs) module
424pub mod error_templates;
425pub mod safe_ops;
426#[cfg(feature = "types")]
427pub mod types;
428#[cfg(feature = "ufuncs")]
429pub mod ufuncs;
430pub mod units;
431pub mod utils;
432pub mod validation;
433
434// Production-level features for enterprise deployments
435pub mod observability;
436pub mod stability;
437pub mod versioning;
438
439// Advanced optimization and AI features
440pub mod neural_architecture_search;
441pub mod quantum_optimization;
442
443// Advanced Mode Ecosystem Integration
444pub mod advanced_ecosystem_integration;
445
446// Advanced JIT Compilation Framework
447pub mod advanced_jit_compilation;
448
449// Advanced Distributed Computing Framework
450pub mod advanced_distributed_computing;
451
452// Advanced Cloud Storage Framework
453// pub mod distributed_storage; // Module not implemented yet
454
455// Advanced Tensor Cores and Automatic Kernel Tuning Framework
456pub mod advanced_tensor_cores;
457
458// Tensor cores optimization modules
459#[cfg(feature = "gpu")]
460pub mod tensor_cores;
461
462// Benchmarking module
463#[cfg(feature = "benchmarking")]
464pub mod benchmarking;
465
466// Re-exports
467#[cfg(feature = "cache")]
468pub use crate::cache::*;
469#[cfg(feature = "cloud")]
470pub use crate::cloud::{
471    CloudConfig, CloudCredentials, CloudError, CloudObjectMetadata, CloudProvider,
472    CloudStorageClient, EncryptionConfig, EncryptionMethod, HttpMethod, ListResult,
473    TransferOptions,
474};
475pub use crate::config::production as config_production;
476pub use crate::config::{
477    get_config, get_config_value, set_config_value, set_global_config, Config, ConfigValue,
478};
479pub use crate::constants::{math, physical, prefixes};
480#[allow(ambiguous_glob_reexports)]
481pub use crate::error::*;
482
483// Re-export the array! macro for convenient array creation
484// This addresses the common pain point where users expect array! to be available
485// directly from scirs2_core instead of requiring import from scirs2_autograd
486//
487// # Example
488//
489// ```rust
490// use scirs2_core::array;
491//
492// let matrix = array![[1, 2, 3], [4, 5, 6]];
493// assert_eq!(matrix.shape(), &[2, 3]);
494// ```
495#[cfg(feature = "gpu")]
496pub use crate::gpu::*;
497pub use crate::io::*;
498#[cfg(feature = "jit")]
499pub use crate::jit::DataType as JitDataType;
500#[cfg(feature = "jit")]
501pub use crate::jit::{
502    CompiledKernel, ExecutionProfile, JitBackend, JitCompiler, JitConfig, JitError, KernelLanguage,
503    KernelSource, OptimizationLevel, TargetArchitecture,
504};
505#[cfg(feature = "logging")]
506pub use crate::logging::*;
507#[cfg(feature = "memory_management")]
508pub use crate::memory::{
509    format_memory_report, generate_memory_report, global_buffer_pool, track_allocation,
510    track_deallocation, track_resize, BufferPool, ChunkProcessor, ChunkProcessor2D,
511    GlobalBufferPool, ZeroCopyView,
512};
513// Legacy re-export from ndarray_ext (kept for backward compatibility)
514pub use crate::ndarray_ext::array as array_legacy;
515
516// Complete ndarray functionality through the unified module
517pub use crate::ndarray::{
518    arr1,
519    arr2,
520    // Essential macros - now available at crate root
521    array,
522    s,
523    // Common types for convenience
524    Array,
525    Array1,
526    Array2,
527    ArrayD,
528    ArrayView,
529    ArrayView1,
530    ArrayView2,
531    ArrayViewMut,
532    Axis,
533    Ix1,
534    Ix2,
535    IxDyn,
536};
537
538#[cfg(feature = "leak_detection")]
539pub use crate::memory::{
540    LeakCheckGuard, LeakDetectionConfig, LeakDetector, LeakReport, LeakType, MemoryCheckpoint,
541    MemoryLeak, ProfilerTool,
542};
543
544#[cfg(feature = "memory_efficient")]
545pub use crate::memory_efficient::{
546    chunk_wise_binary_op, chunk_wise_op, chunk_wise_reduce, create_disk_array, create_mmap,
547    create_temp_mmap, diagonal_view, evaluate, load_chunks, open_mmap, register_fusion,
548    transpose_view, view_as, view_mut_as, AccessMode, AdaptiveChunking, AdaptiveChunkingBuilder,
549    AdaptiveChunkingParams, AdaptiveChunkingResult, ArithmeticOps, BroadcastOps, ChunkIter,
550    ChunkedArray, ChunkingStrategy, DiskBackedArray, FusedOp, LazyArray, LazyOp, LazyOpKind,
551    MemoryMappedArray, MemoryMappedChunkIter, MemoryMappedChunks, MemoryMappedSlice,
552    MemoryMappedSlicing, OpFusion, OutOfCoreArray, ViewMut, ZeroCopyOps,
553};
554
555// Compression-related types are only available with the memory_compression feature
556#[cfg(feature = "memory_compression")]
557pub use crate::memory_efficient::{
558    CompressedMemMapBuilder, CompressedMemMappedArray, CompressionAlgorithm,
559};
560
561// Re-export the parallel memory-mapped array capabilities
562#[cfg(all(feature = "memory_efficient", feature = "parallel"))]
563pub use crate::memory_efficient::MemoryMappedChunksParallel;
564
565#[cfg(feature = "array")]
566pub use crate::array::{
567    is_masked, mask_array, masked_equal, masked_greater, masked_inside, masked_invalid,
568    masked_less, masked_outside, masked_where, record_array_from_typed_arrays,
569    record_array_fromrecords, ArrayError, FieldValue, MaskedArray, Record, RecordArray, NOMASK,
570};
571
572#[cfg(feature = "memory_metrics")]
573pub use crate::memory::metrics::{
574    clear_snapshots,
575    compare_snapshots,
576    // Utility functions
577    format_bytes,
578    format_duration,
579    take_snapshot,
580    MemoryEvent,
581    MemoryEventType,
582    // Core metrics types
583    MemoryMetricsCollector,
584    MemoryMetricsConfig,
585    // Memory snapshots and leak detection
586    MemorySnapshot,
587    SnapshotDiff,
588    // Tracked memory components
589    TrackedBufferPool,
590    TrackedChunkProcessor,
591    TrackedChunkProcessor2D,
592};
593
594#[cfg(feature = "types")]
595pub use crate::batch_conversions::{
596    utils as batch_utils, BatchConversionConfig, BatchConversionResult, BatchConverter,
597    ElementConversionError,
598};
599#[cfg(all(feature = "memory_metrics", feature = "gpu"))]
600pub use crate::memory::metrics::{setup_gpu_memory_tracking, TrackedGpuBuffer, TrackedGpuContext};
601pub use crate::metrics::{
602    global_healthmonitor, global_metrics_registry, Counter, Gauge, HealthCheck, HealthMonitor,
603    HealthStatus, Histogram, MetricPoint, MetricType, MetricValue, Timer,
604};
605#[cfg(feature = "ml_pipeline")]
606pub use crate::ml_pipeline::DataType as MLDataType;
607#[cfg(feature = "ml_pipeline")]
608pub use crate::ml_pipeline::{
609    DataBatch, DataSample, FeatureConstraint, FeatureSchema, FeatureTransformer, FeatureValue,
610    MLPipeline, MLPipelineError, ModelPredictor, ModelType, PipelineConfig, PipelineMetrics,
611    PipelineNode, TransformType,
612};
613pub use crate::numeric::*;
614#[cfg(feature = "parallel")]
615pub use crate::parallel::*;
616#[cfg(feature = "parallel")]
617pub use crate::parallel_ops::{
618    is_parallel_enabled, num_threads, par_chunks, par_chunks_mut, par_join, par_scope,
619};
620// Re-export all parallel traits and types
621#[cfg(feature = "parallel")]
622pub use crate::parallel_ops::*;
623#[cfg(feature = "profiling")]
624pub use crate::profiling::{profiling_memory_tracker, Profiler};
625#[cfg(feature = "random")]
626#[allow(ambiguous_glob_reexports)]
627pub use crate::random::*;
628pub use crate::resource::{
629    get_available_memory, get_performance_tier, get_recommended_chunk_size,
630    get_recommended_thread_count, get_system_resources, get_total_memory, is_gpu_available,
631    is_simd_supported, DiscoveryConfig, PerformanceTier, ResourceDiscovery, SystemResources,
632};
633#[cfg(feature = "simd")]
634pub use crate::simd::*;
635#[cfg(feature = "testing")]
636pub use crate::testing::{TestConfig, TestResult, TestRunner, TestSuite};
637#[cfg(feature = "types")]
638pub use crate::types::{convert, ComplexConversionError, ComplexExt, ComplexOps};
639
640// Re-export complex number types for SCIRS2 POLICY compliance
641pub use num_complex::{Complex, Complex32, Complex64};
642
643// Re-export RNG types for SCIRS2 POLICY compliance
644pub use crate::units::{
645    convert, global_unit_registry, unit_value, Dimension, UnitDefinition, UnitRegistry, UnitSystem,
646    UnitValue,
647};
648pub use crate::utils::*;
649pub use crate::validation::production as validation_production;
650pub use crate::validation::{
651    check_finite, check_in_bounds, check_positive, checkarray_finite, checkshape,
652};
653pub use rand_chacha::{ChaCha12Rng, ChaCha20Rng, ChaCha8Rng};
654
655// ================================
656// Prelude Module
657// ================================
658
659/// Convenient re-exports of commonly used items
660///
661/// Import this module to get quick access to the most frequently used
662/// types, traits, and functions in the SciRS2 ecosystem without needing
663/// to remember specific import paths.
664///
665/// # Example
666///
667/// ```rust
668/// use scirs2_core::prelude::*;
669///
670/// let data = array![[1.0, 2.0], [3.0, 4.0]];
671/// ```
672pub mod prelude;
673
674#[cfg(feature = "data_validation")]
675pub use crate::validation::data::DataType as ValidationDataType;
676#[cfg(feature = "data_validation")]
677pub use crate::validation::data::{
678    Constraint, FieldDefinition, ValidationConfig, ValidationError, ValidationResult,
679    ValidationRule, ValidationSchema, Validator,
680};
681
682// Production-level feature re-exports
683pub use crate::observability::{audit, tracing};
684pub use crate::stability::{
685    global_stability_manager, ApiContract, BreakingChange, BreakingChangeType, ConcurrencyContract,
686    MemoryContract, NumericalContract, PerformanceContract, StabilityGuaranteeManager,
687    StabilityLevel, UsageContext,
688};
689pub use crate::versioning::{
690    compatibility, deprecation, migration, negotiation, semantic, ApiVersion, CompatibilityLevel,
691    SupportStatus, Version, VersionManager,
692};
693
694// Advanced optimization and AI feature re-exports
695pub use crate::neural_architecture_search::{
696    ActivationType, Architecture, ArchitecturePerformance, ConnectionType, HardwareConstraints,
697    LayerType, NASStrategy, NeuralArchitectureSearch, OptimizationObjectives, OptimizerType,
698    SearchResults, SearchSpace,
699};
700pub use crate::quantum_optimization::{
701    OptimizationResult, QuantumOptimizer, QuantumParameters, QuantumState, QuantumStrategy,
702};
703
704// Advanced JIT Compilation re-exports
705// pub use crate::advanced_jit_compilation::{
706//     AdaptiveCodeGenerator, CompilationStatistics, JitAnalytics, JitCompilerConfig, JitProfiler,
707//     KernelCache, KernelMetadata, KernelPerformance, LlvmCompilationEngine, OptimizationResults,
708//     PerformanceImprovement, RuntimeOptimizer, advancedJitCompiler,
709// }; // Missing module
710
711// Advanced Cloud Storage re-exports
712// pub use crate::distributed_storage::{
713//     AdaptiveStreamingEngine, CloudPerformanceAnalytics, CloudProviderConfig, CloudProviderId,
714//     CloudProviderType, CloudSecurityManager, CloudStorageMonitoring, CloudStorageProvider,
715//     DataOptimizationEngine, DownloadRequest, DownloadResponse, IntelligentCacheSystem,
716//     ParallelTransferManager, StreamRequest, advancedCloudConfig,
717//     advancedCloudStorageCoordinator, UploadRequest, UploadResponse,
718// };
719
720// Benchmarking re-exports
721#[cfg(feature = "benchmarking")]
722pub use crate::benchmarking::{
723    BenchmarkConfig, BenchmarkMeasurement, BenchmarkResult, BenchmarkRunner, BenchmarkStatistics,
724    BenchmarkSuite,
725};
726
727/// ``SciRS2`` core version information
728pub const fn _version() -> &'static str {
729    env!("CARGO_PKG_VERSION")
730}
731
732/// Initialize the library (called automatically)
733#[doc(hidden)]
734#[allow(dead_code)]
735pub fn __init() {
736    use std::sync::Once;
737    static INIT: Once = Once::new();
738
739    INIT.call_once(|| {
740        // Initialize API freeze registry
741        crate::api_freeze::initialize_api_freeze();
742    });
743}
744
745// Ensure initialization happens
746#[doc(hidden)]
747#[used]
748#[cfg_attr(target_os = "linux", link_section = ".init_array")]
749#[cfg_attr(target_os = "macos", link_section = "__DATA,__mod_init_func")]
750#[cfg_attr(target_os = "windows", link_section = ".CRT$XCU")]
751static INIT: extern "C" fn() = {
752    extern "C" fn __init_wrapper() {
753        __init();
754    }
755    __init_wrapper
756};