1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
//! # SciRS2 - Scientific Computing for Rust
//!
//! **SciRS2** is a comprehensive scientific computing and AI/ML infrastructure for Rust,
//! providing SciPy-compatible APIs with Rust's performance, safety, and concurrency features.
//!
//! # Feature Flags
//!
//! | Feature | Description | Default |
//! |---------|-------------|---------|
//! | `default` | Core scientific computing modules (`standard`) | ✓ |
//! | `full` | All modules including optional | ✗ |
//! | `standard` | linalg, stats, optimize, integrate, interpolate, fft, special, signal, sparse, spatial, cluster, transform, metrics | ✓ |
//! | `ai` | neural + autograd | ✗ |
//! | `experimental` | ndimage, neural, series, text, io, datasets, graph, vision, autograd | ✗ |
//! | `cuda` | CUDA GPU acceleration (future) | ✗ |
//! | `rocm` | ROCm GPU acceleration (future) | ✗ |
//! | `distributed` | Cluster/distributed computing via scirs2-core | ✗ |
//! | `jit` | JIT compilation and functional transforms (requires `autograd`) | ✗ |
//! | `mobile` | Mobile GPU backends: iOS Metal + Android NNAPI (future) | ✗ |
//! | `nn` | Neural network namespace `scirs2::nn` (requires `neural`) | ✗ |
//! | `symbolic` | Symbolic math integration (future) | ✗ |
//! | `benchmarks` | Benchmark helpers from scirs2-datasets | ✗ |
//! | `oxifft` | High-performance pure-Rust FFT via OxiFFT | ✗ |
//!
//! ## 🎯 Key Features
//!
//! - **SciPy-Compatible APIs**: Familiar function signatures for easy migration from Python
//! - **High Performance**: Rust's zero-cost abstractions with SIMD, parallel, and GPU acceleration
//! - **Type Safety**: Compile-time guarantees preventing runtime errors
//! - **Modular Design**: Use only what you need via feature flags
//! - **Production Ready**: Comprehensive error handling, validation, and stability guarantees
//!
//! ## 📦 Module Overview
//!
//! ### Core Scientific Computing
//!
//! | Module | Description | SciPy Equivalent |
//! |--------|-------------|------------------|
//! | [`linalg`] | Linear algebra (decompositions, eigenvalues, solvers) | `scipy.linalg` |
//! | [`stats`] | Statistical functions and distributions | `scipy.stats` |
//! | [`optimize`] | Optimization algorithms (unconstrained, constrained) | `scipy.optimize` |
//! | [`integrate`] | Numerical integration and ODEs | `scipy.integrate` |
//! | [`interpolate`] | Interpolation methods | `scipy.interpolate` |
//! | [`fft`] | Fast Fourier Transform | `scipy.fft` |
//! | [`signal`] | Signal processing | `scipy.signal` |
//! | [`special`] | Special mathematical functions | `scipy.special` |
//! | [`sparse`] | Sparse matrix operations | `scipy.sparse` |
//! | [`spatial`] | Spatial algorithms (KD-trees, distance metrics) | `scipy.spatial` |
//! | `ndimage` | N-dimensional image processing | `scipy.ndimage` |
//!
//! ### Machine Learning & AI
//!
//! | Module | Description | Python Equivalent |
//! |--------|-------------|-------------------|
//! | `neural` | Neural network building blocks | PyTorch/TensorFlow |
//! | `autograd` | Automatic differentiation | PyTorch autograd |
//! | [`cluster`] | Clustering algorithms (K-means, DBSCAN, etc.) | scikit-learn.cluster |
//! | `metrics` | ML evaluation metrics | scikit-learn.metrics |
//! | `text` | Text processing and NLP | NLTK/spaCy basics |
//! | `vision` | Computer vision utilities | torchvision basics |
//!
//! ### Data & I/O
//!
//! | Module | Description |
//! |--------|-------------|
//! | `datasets` | Sample datasets for testing and learning |
//! | `io` | Input/output utilities (CSV, HDF5, Parquet) |
//! | `transform` | Data transformation pipelines |
//! | `series` | Time series analysis |
//! | `graph` | Graph processing algorithms |
//!
//! ### Utilities
//!
//! | Module | Description |
//! |--------|-------------|
//! | [`constants`] | Physical and mathematical constants |
//! | `error` (module) | Error types and handling |
//! | [`validation`] | Input validation utilities |
//!
//! **Note**: ML optimization algorithms have been moved to the independent
//! [OptiRS](https://github.com/cool-japan/optirs) project.
//!
//! ## 🚀 Quick Start
//!
//! ### Installation
//!
//! Add SciRS2 to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! scirs2 = { version = "0.4.2", features = ["linalg", "stats"] }
//! ```
//!
//! Or install all features:
//!
//! ```toml
//! [dependencies]
//! scirs2 = { version = "0.4.2", features = ["full"] }
//! ```
//!
//! ### Linear Algebra Example
//!
//! ```rust,no_run
//! # use scirs2_core::ndarray::array;
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Matrix operations
//! let a = array![[1.0, 2.0], [3.0, 4.0]];
//!
//! // Determinant
//! let det = scirs2::linalg::det(&a.view(), None)?;
//! println!("Determinant: {}", det);
//!
//! // Matrix inverse
//! let inv = scirs2::linalg::inv(&a.view(), None)?;
//! println!("Inverse:\n{:?}", inv);
//!
//! // SVD decomposition
//! let (u, s, vt) = scirs2::linalg::svd(&a.view(), true, None)?;
//! println!("Singular values: {:?}", s);
//! # Ok(())
//! # }
//! ```
//!
//! ### Statistics Example
//!
//! ```rust,no_run
//! # use scirs2_core::ndarray::array;
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let data = array![1.0, 2.0, 3.0, 4.0, 5.0];
//!
//! // Descriptive statistics
//! let mean = scirs2::stats::mean(&data.view())?;
//! let std = scirs2::stats::std(&data.view(), 0, None)?;
//! let median = scirs2::stats::median(&data.view())?;
//!
//! println!("Mean: {}, Std: {}, Median: {}", mean, std, median);
//!
//! // Statistical distributions
//! use scirs2::stats::distributions::Normal;
//! let normal = Normal::new(0.0, 1.0)?;
//! let samples = normal.rvs(1000)?;
//! println!("Generated {} samples", samples.len());
//! # Ok(())
//! # }
//! ```
//!
//! ### Neural Network Example
//!
//! ```rust,ignore
//! use scirs2::neural::{Sequential, Dense, ReLU};
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Build a simple neural network
//! let mut model = Sequential::new();
//! model.add(Dense::new(784, 128)?);
//! model.add(ReLU::new());
//! model.add(Dense::new(128, 10)?);
//!
//! // Forward pass
//! // let output = model.forward(&input)?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## 🎨 Feature Flags
//!
//! Control which modules to include:
//!
//! ### Core Modules
//!
//! - `linalg` - Linear algebra operations
//! - `stats` - Statistical functions
//! - `optimize` - Optimization algorithms
//! - `integrate` - Numerical integration
//! - `interpolate` - Interpolation methods
//! - `fft` - Fast Fourier Transform
//! - `special` - Special functions
//! - `signal` - Signal processing
//! - `sparse` - Sparse matrices
//! - `spatial` - Spatial algorithms
//!
//! ### ML/AI Modules
//!
//! - `neural` - Neural networks
//! - `autograd` - Automatic differentiation
//! - `cluster` - Clustering algorithms
//! - `metrics` - ML metrics
//! - `text` - Text processing
//! - `vision` - Computer vision
//!
//! ### Data Modules
//!
//! - `datasets` - Sample datasets
//! - `io` - I/O utilities
//! - `transform` - Data transformation
//! - `series` - Time series
//! - `graph` - Graph processing
//! - `ndimage` - Image processing
//!
//! ### Convenience Features
//!
//! - `full` - Enable all features
//! - `default` - Enable commonly used features
//!
//! ## 🏗️ Architecture
//!
//! SciRS2 follows a layered architecture:
//!
//! ```text
//! ┌─────────────────────────────────────────┐
//! │ User Applications │
//! └─────────────────────────────────────────┘
//! ▼
//! ┌─────────────────────────────────────────┐
//! │ scirs2 (Unified Interface) │
//! │ - Feature-gated re-exports │
//! │ - Unified prelude │
//! └─────────────────────────────────────────┘
//! ▼
//! ┌─────────────────────────────────────────┐
//! │ Domain Modules │
//! │ linalg, stats, neural, etc. │
//! └─────────────────────────────────────────┘
//! ▼
//! ┌─────────────────────────────────────────┐
//! │ scirs2-core (Foundation) │
//! │ - Error handling │
//! │ - SIMD/Parallel/GPU abstractions │
//! │ - Memory management │
//! │ - Validation utilities │
//! └─────────────────────────────────────────┘
//! ```
//!
//! ## 📊 Performance
//!
//! SciRS2 leverages multiple optimization strategies:
//!
//! - **SIMD**: Automatic vectorization for array operations
//! - **Parallel**: Multi-threaded execution via Rayon
//! - **GPU**: CUDA/Metal/OpenCL support for accelerated computing
//! - **BLAS/LAPACK**: Native library bindings for optimal performance
//!
//! Benchmark comparisons with SciPy show 2-10x speedups for many operations
//! (see `benchmarks/` directory for details).
//!
//! ## 🔒 Stability & Versioning
//!
//! SciRS2 follows semantic versioning and provides:
//!
//! - **API Stability**: Stable releases maintain API compatibility
//! - **Deprecation Policy**: 2-release deprecation cycle
//! - **Production Features**: Enterprise-grade error handling and diagnostics
//!
//! Current version: **0.4.2**
//!
//! ## 🤝 Ecosystem Integration
//!
//! SciRS2 integrates with the Rust scientific ecosystem:
//!
//! - **ndarray**: Core array operations
//! - **num-traits**: Generic numeric operations
//! - **OptiRS**: Advanced optimization (formerly scirs2-optim)
//! - **nalgebra**: Alternative linear algebra (interoperable)
//!
//! ## 📚 Additional Resources
//!
//! - [GitHub Repository](https://github.com/cool-japan/scirs)
//! - [API Documentation](https://docs.rs/scirs2)
//! - [Examples](https://github.com/cool-japan/scirs/tree/master/examples)
//! - [Migration Guide from SciPy](https://github.com/cool-japan/scirs/blob/master/docs/migration.md)
//!
//! ## 📜 License
//!
//! Licensed under Apache License, Version 2.0.
// Re-export from scirs2-core
pub use cache;
pub use logging;
pub use memory;
pub use profiling;
pub use ;
// Optional modules (enabled via features)
pub use scirs2_linalg as linalg;
pub use scirs2_stats as stats;
pub use scirs2_integrate as integrate;
pub use scirs2_interpolate as interpolate;
pub use scirs2_optimize as optimize;
pub use scirs2_fft as fft;
pub use scirs2_special as special;
pub use scirs2_signal as signal;
pub use scirs2_sparse as sparse;
pub use scirs2_spatial as spatial;
pub use scirs2_cluster as cluster;
pub use scirs2_ndimage as ndimage;
pub use scirs2_io as io;
pub use scirs2_datasets as datasets;
pub use scirs2_neural as neural;
// optim module moved to independent OptiRS project
pub use scirs2_graph as graph;
pub use scirs2_transform as transform;
pub use scirs2_metrics as metrics;
pub use scirs2_text as text;
pub use scirs2_vision as vision;
pub use scirs2_series as series;
pub use scirs2_autograd as autograd;
/// Version information
/// Re-export of common utilities and types.
///
/// Import everything with `use scirs2::prelude::*;` for the most convenient experience.
/// All items below that depend on optional features are conditionally compiled.
/// Neural network building-block re-exports under a single `scirs2::nn` namespace.
///
/// Enable with `features = ["nn"]` (implies `neural`).
///
/// # Example
/// ```rust,ignore
/// use scirs2::nn::{Sequential, Dense, ReLU, Sigmoid};
/// ```
/// Functional array transformation re-exports (`vmap`, `pmap`).
///
/// Enable with `features = ["jit"]` (implies `autograd`).
///
/// - `vmap` — vectorised map: applies a scalar function over a batch dimension
/// - `pmap` — parallel map: distributes computation across available threads
///
/// # Example
/// ```rust,ignore
/// use scirs2::transforms::{vmap, pmap};
/// ```
// Public API
/// SciRS2 version information