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
//! WebAssembly bindings for NumRS2
//!
//! This module provides JavaScript-friendly bindings for NumRS2 functionality,
//! enabling the use of NumRS2 in web browsers and Node.js environments.
//!
//! # Features
//!
//! - **Array Operations**: Create and manipulate N-dimensional arrays from JavaScript
//! - **Linear Algebra**: Matrix operations, decompositions, and solvers
//! - **Statistics**: Statistical functions and probability distributions
//! - **SIMD Optimization**: Automatic SIMD acceleration where supported
//!
//! # Usage
//!
//! This module is only available when compiling with the `wasm` feature flag:
//!
//! ```toml
//! [dependencies]
//! numrs2 = { version = "0.3.0", features = ["wasm"] }
//! ```
//!
//! # Building
//!
//! To build for WebAssembly:
//!
//! ```bash
//! wasm-pack build --target web --features wasm
//! ```
//!
//! # Example
//!
//! ```javascript
//! import init, { WasmArray } from './pkg/numrs2.js';
//!
//! async function main() {
//! await init();
//!
//! // Create a 2x2 array
//! const arr = WasmArray.zeros([2, 2]);
//! console.log(arr.shape());
//! }
//! ```
//!
//! # SCIRS2 Integration
//!
//! All WebAssembly bindings follow the SCIRS2 ecosystem policy:
//! - Use `scirs2_core::ndarray` for array operations
//! - Use `scirs2_core::random` for random number generation
//! - Use `scirs2-linalg` for linear algebra (pure Rust via OxiBLAS)
//! - No direct dependencies on C/C++ libraries
//!
//! # Performance
//!
//! NumRS2's WebAssembly bindings leverage:
//! - SIMD instructions where supported by the browser
//! - Efficient memory layout for minimal JavaScript ↔ Rust boundary crossings
//! - Zero-copy data transfer where possible
//!
//! # Error Handling
//!
//! All public API functions return `Result` types and do not use `unwrap()`.
//! Errors are properly converted to JavaScript exceptions with meaningful messages.
use *;
// Public submodules
// Re-export commonly used types
pub use WasmArray;
pub use ;
/// Initialize the WebAssembly module
///
/// This function should be called before using any NumRS2 functionality
/// in JavaScript. It sets up panic hooks for better error messages.
///
/// # Example
///
/// ```javascript
/// import init from './pkg/numrs2.js';
/// await init();
/// ```
/// Get the NumRS2 version string
///
/// Returns the version of the NumRS2 library.
///
/// # Example
///
/// ```javascript
/// import { get_version } from './pkg/numrs2.js';
/// console.log(get_version()); // "0.3.0"
/// ```
/// Check if SIMD is available in the current environment
///
/// Returns true if SIMD operations are available in the WebAssembly runtime.
///
/// # Example
///
/// ```javascript
/// import { is_simd_available } from './pkg/numrs2.js';
/// if (is_simd_available()) {
/// console.log("SIMD acceleration available!");
/// }
/// ```