scirs2_fft/compressed_sensing/types.rs
1//! Types for compressed sensing via FFT-based measurements.
2
3/// Configuration for compressed sensing recovery algorithms.
4#[derive(Debug, Clone)]
5pub struct CsConfig {
6 /// Target sparsity (number of non-zero coefficients).
7 pub sparsity: usize,
8 /// Maximum number of iterations.
9 pub max_iter: usize,
10 /// Convergence tolerance.
11 pub tol: f64,
12}
13
14impl Default for CsConfig {
15 fn default() -> Self {
16 Self {
17 sparsity: 5,
18 max_iter: 100,
19 tol: 1e-6,
20 }
21 }
22}
23
24/// Sparse frequency-domain measurements (partial DFT observations).
25///
26/// Represents y = A·x where A is a partial DFT matrix built from `indices`.
27#[derive(Debug, Clone)]
28pub struct Measurement {
29 /// Which frequency bins were observed (row indices of the DFT matrix).
30 pub indices: Vec<usize>,
31 /// Observed values: real and imaginary parts interleaved as `[re0, im0, re1, im1, …]`.
32 pub values: Vec<f64>,
33}
34
35/// Result of a compressed sensing recovery.
36#[derive(Debug, Clone)]
37pub struct CsResult {
38 /// Recovered time-domain signal of length N.
39 pub recovered: Vec<f64>,
40 /// Number of iterations performed.
41 pub iterations: usize,
42 /// Final residual ‖y − A·x‖₂.
43 pub residual: f64,
44}
45
46/// Recovery algorithm to use.
47#[non_exhaustive]
48#[derive(Debug, Clone, Copy, PartialEq, Eq)]
49pub enum RecoveryMethod {
50 /// Orthogonal Matching Pursuit.
51 Omp,
52 /// Iterative Shrinkage / Thresholding (ISTA / FISTA).
53 Ista,
54 /// Alternating Direction Method of Multipliers.
55 Admm,
56 /// Compressive Sampling Matching Pursuit.
57 CoSaMP,
58}