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.3", 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::crate::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.3** (Released December 17, 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 = "python")]
415pub mod python;
416#[cfg(feature = "random")]
417pub mod random;
418pub mod resource;
419#[cfg(feature = "simd")]
420pub mod simd;
421pub mod simd_aligned;
422pub mod simd_ops;
423#[cfg(feature = "simd")]
424pub mod simd_ops_polynomial;
425#[cfg(feature = "testing")]
426pub mod testing;
427// Universal Functions (ufuncs) module
428pub mod error_templates;
429pub mod safe_ops;
430#[cfg(feature = "types")]
431pub mod types;
432#[cfg(feature = "ufuncs")]
433pub mod ufuncs;
434pub mod units;
435pub mod utils;
436pub mod validation;
437
438// Production-level features for enterprise deployments
439pub mod observability;
440pub mod stability;
441pub mod versioning;
442
443// Advanced optimization and AI features
444pub mod neural_architecture_search;
445pub mod quantum_optimization;
446
447// Advanced Mode Ecosystem Integration
448pub mod advanced_ecosystem_integration;
449
450// Advanced JIT Compilation Framework
451pub mod advanced_jit_compilation;
452
453// Advanced Distributed Computing Framework
454pub mod advanced_distributed_computing;
455
456// Advanced Cloud Storage Framework
457// pub mod distributed_storage; // Module not implemented yet
458
459// Advanced Tensor Cores and Automatic Kernel Tuning Framework
460pub mod advanced_tensor_cores;
461
462// Tensor cores optimization modules
463#[cfg(feature = "gpu")]
464pub mod tensor_cores;
465
466// Benchmarking module
467#[cfg(feature = "benchmarking")]
468pub mod benchmarking;
469
470// Re-exports
471#[cfg(feature = "cache")]
472pub use crate::cache::*;
473#[cfg(feature = "cloud")]
474pub use crate::cloud::{
475    CloudConfig, CloudCredentials, CloudError, CloudObjectMetadata, CloudProvider,
476    CloudStorageClient, EncryptionConfig, EncryptionMethod, HttpMethod, ListResult,
477    TransferOptions,
478};
479pub use crate::config::production as config_production;
480pub use crate::config::{
481    get_config, get_config_value, set_config_value, set_global_config, Config, ConfigValue,
482};
483pub use crate::constants::{math, physical, prefixes};
484#[allow(ambiguous_glob_reexports)]
485pub use crate::error::*;
486
487// Re-export the array! macro for convenient array creation
488// This addresses the common pain point where users expect array! to be available
489// directly from scirs2_core instead of requiring import from scirs2_autograd
490//
491// # Example
492//
493// ```rust
494// use scirs2_core::array;
495//
496// let matrix = array![[1, 2, 3], [4, 5, 6]];
497// assert_eq!(matrix.shape(), &[2, 3]);
498// ```
499#[cfg(feature = "gpu")]
500pub use crate::gpu::*;
501pub use crate::io::*;
502#[cfg(feature = "jit")]
503pub use crate::jit::DataType as JitDataType;
504#[cfg(feature = "jit")]
505pub use crate::jit::{
506    CompiledKernel, ExecutionProfile, JitBackend, JitCompiler, JitConfig, JitError, KernelLanguage,
507    KernelSource, OptimizationLevel, TargetArchitecture,
508};
509#[cfg(feature = "logging")]
510pub use crate::logging::*;
511#[cfg(feature = "memory_management")]
512pub use crate::memory::{
513    format_memory_report, generate_memory_report, global_buffer_pool, track_allocation,
514    track_deallocation, track_resize, BufferPool, ChunkProcessor, ChunkProcessor2D,
515    GlobalBufferPool, ZeroCopyView,
516};
517// Legacy re-export from ndarray_ext (kept for backward compatibility)
518pub use crate::ndarray_ext::array as array_legacy;
519
520// Complete ndarray functionality through the unified module
521// Use ndarray_ext which has the correct re-exports from ::ndarray
522pub use crate::ndarray_ext::{
523    arr1,
524    arr2,
525    // Essential macros - now available at crate root
526    array,
527    s,
528    // Common types for convenience
529    Array,
530    Array1,
531    Array2,
532    ArrayD,
533    ArrayView,
534    ArrayView1,
535    ArrayView2,
536    ArrayViewMut,
537    Axis,
538    Ix1,
539    Ix2,
540    IxDyn,
541};
542
543#[cfg(feature = "leak_detection")]
544pub use crate::memory::{
545    LeakCheckGuard, LeakDetectionConfig, LeakDetector, LeakReport, LeakType, MemoryCheckpoint,
546    MemoryLeak, ProfilerTool,
547};
548
549#[cfg(feature = "memory_efficient")]
550pub use crate::memory_efficient::{
551    chunk_wise_binary_op, chunk_wise_op, chunk_wise_reduce, create_disk_array, create_mmap,
552    create_temp_mmap, diagonal_view, evaluate, load_chunks, open_mmap, register_fusion,
553    transpose_view, view_as, view_mut_as, AccessMode, AdaptiveChunking, AdaptiveChunkingBuilder,
554    AdaptiveChunkingParams, AdaptiveChunkingResult, ArithmeticOps, BroadcastOps, ChunkIter,
555    ChunkedArray, ChunkingStrategy, DiskBackedArray, FusedOp, LazyArray, LazyOp, LazyOpKind,
556    MemoryMappedArray, MemoryMappedChunkIter, MemoryMappedChunks, MemoryMappedSlice,
557    MemoryMappedSlicing, OpFusion, OutOfCoreArray, ViewMut, ZeroCopyOps,
558};
559
560// Compression-related types are only available with the memory_compression feature
561#[cfg(feature = "memory_compression")]
562pub use crate::memory_efficient::{
563    CompressedMemMapBuilder, CompressedMemMappedArray, CompressionAlgorithm,
564};
565
566// Re-export the parallel memory-mapped array capabilities
567#[cfg(all(feature = "memory_efficient", feature = "parallel"))]
568pub use crate::memory_efficient::MemoryMappedChunksParallel;
569
570#[cfg(feature = "array")]
571pub use crate::array::{
572    is_masked, mask_array, masked_equal, masked_greater, masked_inside, masked_invalid,
573    masked_less, masked_outside, masked_where, record_array_from_typed_arrays,
574    record_array_fromrecords, ArrayError, FieldValue, MaskedArray, Record, RecordArray, NOMASK,
575};
576
577#[cfg(feature = "memory_metrics")]
578pub use crate::memory::metrics::{
579    clear_snapshots,
580    compare_snapshots,
581    // Utility functions
582    format_bytes,
583    format_duration,
584    take_snapshot,
585    MemoryEvent,
586    MemoryEventType,
587    // Core metrics types
588    MemoryMetricsCollector,
589    MemoryMetricsConfig,
590    // Memory snapshots and leak detection
591    MemorySnapshot,
592    SnapshotDiff,
593    // Tracked memory components
594    TrackedBufferPool,
595    TrackedChunkProcessor,
596    TrackedChunkProcessor2D,
597};
598
599#[cfg(feature = "types")]
600pub use crate::batch_conversions::{
601    utils as batch_utils, BatchConversionConfig, BatchConversionResult, BatchConverter,
602    ElementConversionError,
603};
604#[cfg(all(feature = "memory_metrics", feature = "gpu"))]
605pub use crate::memory::metrics::{setup_gpu_memory_tracking, TrackedGpuBuffer, TrackedGpuContext};
606pub use crate::metrics::{
607    global_healthmonitor, global_metrics_registry, Counter, Gauge, HealthCheck, HealthMonitor,
608    HealthStatus, Histogram, MetricPoint, MetricType, MetricValue, Timer,
609};
610#[cfg(feature = "ml_pipeline")]
611pub use crate::ml_pipeline::DataType as MLDataType;
612#[cfg(feature = "ml_pipeline")]
613pub use crate::ml_pipeline::{
614    DataBatch, DataSample, FeatureConstraint, FeatureSchema, FeatureTransformer, FeatureValue,
615    MLPipeline, MLPipelineError, ModelPredictor, ModelType, PipelineConfig, PipelineMetrics,
616    PipelineNode, TransformType,
617};
618pub use crate::numeric::*;
619#[cfg(feature = "parallel")]
620pub use crate::parallel::*;
621#[cfg(feature = "parallel")]
622pub use crate::parallel_ops::{
623    is_parallel_enabled, num_threads, par_chunks, par_chunks_mut, par_join, par_scope,
624};
625// Re-export all parallel traits and types
626#[cfg(feature = "parallel")]
627pub use crate::parallel_ops::*;
628#[cfg(feature = "profiling")]
629pub use crate::profiling::{profiling_memory_tracker, Profiler};
630#[cfg(feature = "random")]
631#[allow(ambiguous_glob_reexports)]
632pub use crate::random::*;
633pub use crate::resource::{
634    get_available_memory, get_performance_tier, get_recommended_chunk_size,
635    get_recommended_thread_count, get_system_resources, get_total_memory, is_gpu_available,
636    is_simd_supported, DiscoveryConfig, PerformanceTier, ResourceDiscovery, SystemResources,
637};
638#[cfg(feature = "simd")]
639pub use crate::simd::*;
640#[cfg(feature = "testing")]
641pub use crate::testing::{TestConfig, TestResult, TestRunner, TestSuite};
642#[cfg(feature = "types")]
643pub use crate::types::{convert, ComplexConversionError, ComplexExt, ComplexOps};
644
645// Re-export complex number types for SCIRS2 POLICY compliance
646pub use num_complex::{Complex, Complex32, Complex64};
647
648// Re-export RNG types for SCIRS2 POLICY compliance
649pub use crate::units::{
650    convert, global_unit_registry, unit_value, Dimension, UnitDefinition, UnitRegistry, UnitSystem,
651    UnitValue,
652};
653pub use crate::utils::*;
654pub use crate::validation::production as validation_production;
655pub use crate::validation::{
656    check_finite, check_in_bounds, check_positive, checkarray_finite, checkshape,
657};
658pub use rand_chacha::{ChaCha12Rng, ChaCha20Rng, ChaCha8Rng};
659
660// ================================
661// Prelude Module
662// ================================
663
664/// Convenient re-exports of commonly used items
665///
666/// Import this module to get quick access to the most frequently used
667/// types, traits, and functions in the SciRS2 ecosystem without needing
668/// to remember specific import paths.
669///
670/// # Example
671///
672/// ```rust
673/// use scirs2_core::prelude::*;
674///
675/// let data = array![[1.0, 2.0], [3.0, 4.0]];
676/// ```
677pub mod prelude;
678
679#[cfg(feature = "data_validation")]
680pub use crate::validation::data::DataType as ValidationDataType;
681#[cfg(feature = "data_validation")]
682pub use crate::validation::data::{
683    Constraint, FieldDefinition, ValidationConfig, ValidationError, ValidationResult,
684    ValidationRule, ValidationSchema, Validator,
685};
686
687// Production-level feature re-exports
688pub use crate::observability::{audit, tracing};
689pub use crate::stability::{
690    global_stability_manager, ApiContract, BreakingChange, BreakingChangeType, ConcurrencyContract,
691    MemoryContract, NumericalContract, PerformanceContract, StabilityGuaranteeManager,
692    StabilityLevel, UsageContext,
693};
694pub use crate::versioning::{
695    compatibility, deprecation, migration, negotiation, semantic, ApiVersion, CompatibilityLevel,
696    SupportStatus, Version, VersionManager,
697};
698
699// Advanced optimization and AI feature re-exports
700pub use crate::neural_architecture_search::{
701    ActivationType, Architecture, ArchitecturePerformance, ConnectionType, HardwareConstraints,
702    LayerType, NASStrategy, NeuralArchitectureSearch, OptimizationObjectives, OptimizerType,
703    SearchResults, SearchSpace,
704};
705pub use crate::quantum_optimization::{
706    OptimizationResult, QuantumOptimizer, QuantumParameters, QuantumState, QuantumStrategy,
707};
708
709// Advanced JIT Compilation re-exports
710// pub use crate::advanced_jit_compilation::{
711//     AdaptiveCodeGenerator, CompilationStatistics, JitAnalytics, JitCompilerConfig, JitProfiler,
712//     KernelCache, KernelMetadata, KernelPerformance, LlvmCompilationEngine, OptimizationResults,
713//     PerformanceImprovement, RuntimeOptimizer, advancedJitCompiler,
714// }; // Missing module
715
716// Advanced Cloud Storage re-exports
717// pub use crate::distributed_storage::{
718//     AdaptiveStreamingEngine, CloudPerformanceAnalytics, CloudProviderConfig, CloudProviderId,
719//     CloudProviderType, CloudSecurityManager, CloudStorageMonitoring, CloudStorageProvider,
720//     DataOptimizationEngine, DownloadRequest, DownloadResponse, IntelligentCacheSystem,
721//     ParallelTransferManager, StreamRequest, advancedCloudConfig,
722//     advancedCloudStorageCoordinator, UploadRequest, UploadResponse,
723// };
724
725// Benchmarking re-exports
726#[cfg(feature = "benchmarking")]
727pub use crate::benchmarking::{
728    BenchmarkConfig, BenchmarkMeasurement, BenchmarkResult, BenchmarkRunner, BenchmarkStatistics,
729    BenchmarkSuite,
730};
731
732/// ``SciRS2`` core version information
733pub const fn _version() -> &'static str {
734    env!("CARGO_PKG_VERSION")
735}
736
737/// Initialize the library (called automatically)
738#[doc(hidden)]
739#[allow(dead_code)]
740pub fn __init() {
741    use std::sync::Once;
742    static INIT: Once = Once::new();
743
744    INIT.call_once(|| {
745        // Initialize API freeze registry
746        crate::api_freeze::initialize_api_freeze();
747    });
748}
749
750// Ensure initialization happens
751#[doc(hidden)]
752#[used]
753#[cfg_attr(target_os = "linux", link_section = ".init_array")]
754#[cfg_attr(target_os = "macos", link_section = "__DATA,__mod_init_func")]
755#[cfg_attr(target_os = "windows", link_section = ".CRT$XCU")]
756static INIT: extern "C" fn() = {
757    extern "C" fn __init_wrapper() {
758        __init();
759    }
760    __init_wrapper
761};