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