quantrs2_device/process_tomography/
fallback.rs1use scirs2_core::ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
5pub const fn mean(_data: &ArrayView1<f64>) -> Result<f64, String> {
7 Ok(0.0)
8}
9
10pub const fn std(_data: &ArrayView1<f64>, _ddof: i32) -> Result<f64, String> {
12 Ok(1.0)
13}
14
15pub const fn pearsonr(
17 _x: &ArrayView1<f64>,
18 _y: &ArrayView1<f64>,
19 _alt: &str,
20) -> Result<(f64, f64), String> {
21 Ok((0.0, 0.5))
22}
23
24pub const fn trace(_matrix: &ArrayView2<f64>) -> Result<f64, String> {
26 Ok(1.0)
27}
28
29pub fn inv(_matrix: &ArrayView2<f64>) -> Result<Array2<f64>, String> {
31 Ok(Array2::eye(2))
32}
33
34pub struct OptimizeResult {
36 pub x: Array1<f64>,
37 pub fun: f64,
38 pub success: bool,
39 pub nit: usize,
40}
41
42pub fn minimize(
44 _func: fn(&Array1<f64>) -> f64,
45 _x0: &Array1<f64>,
46 _method: &str,
47) -> Result<OptimizeResult, String> {
48 Ok(OptimizeResult {
49 x: Array1::zeros(2),
50 fun: 0.0,
51 success: true,
52 nit: 0,
53 })
54}
55
56pub fn eig(
58 _matrix: &ArrayView2<f64>,
59) -> Result<
60 (
61 Array1<scirs2_core::Complex64>,
62 Array2<scirs2_core::Complex64>,
63 ),
64 String,
65> {
66 let eigenvalues = Array1::from_vec(vec![
67 scirs2_core::Complex64::new(1.0, 0.0),
68 scirs2_core::Complex64::new(0.0, 0.0),
69 ]);
70 let eigenvectors = Array2::from_shape_vec(
71 (2, 2),
72 vec![
73 scirs2_core::Complex64::new(1.0, 0.0),
74 scirs2_core::Complex64::new(0.0, 0.0),
75 scirs2_core::Complex64::new(0.0, 0.0),
76 scirs2_core::Complex64::new(1.0, 0.0),
77 ],
78 )
79 .map_err(|e| format!("Array creation error: {e}"))?;
80
81 Ok((eigenvalues, eigenvectors))
82}
83
84pub const fn det(_matrix: &ArrayView2<f64>) -> Result<f64, String> {
86 Ok(1.0)
87}
88
89pub fn qr(_matrix: &ArrayView2<f64>) -> Result<(Array2<f64>, Array2<f64>), String> {
91 Ok((Array2::eye(2), Array2::eye(2)))
92}
93
94pub fn svd(_matrix: &ArrayView2<f64>) -> Result<(Array2<f64>, Array1<f64>, Array2<f64>), String> {
96 Ok((Array2::eye(2), Array1::ones(2), Array2::eye(2)))
97}
98
99pub const fn matrix_norm(_matrix: &ArrayView2<f64>, _ord: Option<&str>) -> Result<f64, String> {
101 Ok(1.0)
102}
103
104pub fn cholesky(_matrix: &ArrayView2<f64>) -> Result<Array2<f64>, String> {
106 Ok(Array2::eye(2))
107}
108
109pub const fn var(_data: &ArrayView1<f64>, _ddof: i32) -> Result<f64, String> {
111 Ok(1.0)
112}
113
114pub fn corrcoef(_x: &ArrayView1<f64>, _y: &ArrayView1<f64>) -> Result<Array2<f64>, String> {
116 Ok(Array2::eye(2))
117}
118
119pub const fn spearmanr(
121 _x: &ArrayView1<f64>,
122 _y: &ArrayView1<f64>,
123 _alternative: &str,
124) -> Result<(f64, f64), String> {
125 Ok((0.0, 0.5))
126}
127
128pub const fn ttest_1samp(
130 _a: &ArrayView1<f64>,
131 _popmean: f64,
132 _alternative: &str,
133) -> Result<TTestResult, String> {
134 Ok(TTestResult {
135 statistic: 0.0,
136 pvalue: 0.5,
137 })
138}
139
140pub const fn ttest_ind(
142 _a: &ArrayView1<f64>,
143 _b: &ArrayView1<f64>,
144 _alternative: &str,
145) -> Result<TTestResult, String> {
146 Ok(TTestResult {
147 statistic: 0.0,
148 pvalue: 0.5,
149 })
150}
151
152pub const fn ks_2samp(
154 _data1: &ArrayView1<f64>,
155 _data2: &ArrayView1<f64>,
156 _alternative: &str,
157) -> Result<KSTestResult, String> {
158 Ok(KSTestResult {
159 statistic: 0.0,
160 pvalue: 0.5,
161 })
162}
163
164pub const fn shapiro_wilk(_data: &ArrayView1<f64>) -> Result<SWTestResult, String> {
166 Ok(SWTestResult {
167 statistic: 0.95,
168 pvalue: 0.1,
169 })
170}
171
172#[derive(Debug, Clone)]
174pub struct TTestResult {
175 pub statistic: f64,
176 pub pvalue: f64,
177}
178
179#[derive(Debug, Clone)]
181pub struct KSTestResult {
182 pub statistic: f64,
183 pub pvalue: f64,
184}
185
186#[derive(Debug, Clone)]
188pub struct SWTestResult {
189 pub statistic: f64,
190 pub pvalue: f64,
191}
192
193#[derive(Debug, Clone)]
195pub enum Alternative {
196 TwoSided,
197 Less,
198 Greater,
199}
200
201pub mod distributions {
203 use super::*;
204
205 pub mod norm {
207 pub const fn pdf(_x: f64, _loc: f64, _scale: f64) -> f64 {
209 0.4
210 }
211
212 pub const fn cdf(_x: f64, _loc: f64, _scale: f64) -> f64 {
214 0.5
215 }
216
217 pub const fn ppf(_q: f64, _loc: f64, _scale: f64) -> f64 {
219 0.0
220 }
221 }
222
223 pub mod chi2 {
225 pub const fn pdf(_x: f64, _df: f64) -> f64 {
227 0.1
228 }
229
230 pub const fn cdf(_x: f64, _df: f64) -> f64 {
232 0.5
233 }
234
235 pub const fn ppf(_q: f64, _df: f64) -> f64 {
237 1.0
238 }
239 }
240
241 pub mod gamma {
243 pub const fn pdf(_x: f64, _a: f64, _scale: f64) -> f64 {
245 0.2
246 }
247
248 pub const fn cdf(_x: f64, _a: f64, _scale: f64) -> f64 {
250 0.5
251 }
252
253 pub const fn ppf(_q: f64, _a: f64, _scale: f64) -> f64 {
255 1.0
256 }
257 }
258}
259
260pub mod graph {
262 use super::*;
263
264 pub fn betweenness_centrality(_graph: &Array2<f64>) -> Result<Array1<f64>, String> {
266 Ok(Array1::ones(2))
267 }
268
269 pub fn closeness_centrality(_graph: &Array2<f64>) -> Result<Array1<f64>, String> {
271 Ok(Array1::ones(2))
272 }
273
274 pub fn minimum_spanning_tree(_graph: &Array2<f64>) -> Result<Array2<f64>, String> {
276 Ok(Array2::eye(2))
277 }
278
279 pub fn shortest_path(
281 _graph: &Array2<f64>,
282 _start: usize,
283 _end: usize,
284 ) -> Result<Vec<usize>, String> {
285 Ok(vec![0, 1])
286 }
287
288 pub fn strongly_connected_components(_graph: &Array2<f64>) -> Result<Vec<Vec<usize>>, String> {
290 Ok(vec![vec![0], vec![1]])
291 }
292
293 pub struct Graph {
295 pub adjacency_matrix: Array2<f64>,
296 }
297
298 impl Graph {
299 pub const fn new(adjacency_matrix: Array2<f64>) -> Self {
300 Self { adjacency_matrix }
301 }
302 }
303}