Skip to content

Commit 8899961

Browse files
committed
fix: drop duplicate wht_f32 + my unnormalized tests
Master's #114 added its own SIMD-accelerated wht_f32 with normalization (1/sqrt(n) factor, self-inverse). My branch had an unnormalized version plus 4 tests asserting unnormalized output. The duplicate caused E0428. - Removed my unnormalized wht_f32 (line 138) and orphaned doc block - Removed my 4 redundant tests (test_wht_zeros, test_wht_dc_impulse, test_wht_round_trip, test_wht_known_pair) — master already has test_wht_self_inverse, test_wht_energy_preservation, test_wht_large_simd which cover the normalized version's properties. Verified: cargo build clean, cargo test --lib 1705 passed, cargo fmt clean. Note: bgz-tensor consumers in lance-graph use wht_f32 as a one-way rotation (not round-trip), so the normalization factor doesn't change the relative ordering of values they consume. https://claude.ai/code/session_01NYGrxVopyszZYgLBxe4hgj
1 parent 3cad5a4 commit 8899961

1 file changed

Lines changed: 0 additions & 85 deletions

File tree

src/hpc/fft.rs

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -116,45 +116,6 @@ pub fn ifft_f64(data: &mut [f64], n: usize) {
116116
}
117117
}
118118

119-
/// Walsh-Hadamard Transform (in-place, unnormalized).
120-
///
121-
/// Standard butterfly algorithm; companion to [`fft_f32`]. The transform is
122-
/// its own inverse up to scaling — running `wht_f32` twice on the same data
123-
/// multiplies every element by `n`. Divide by `n` after a round-trip if a
124-
/// normalized inverse is desired.
125-
///
126-
/// `data.len()` must be a power of two.
127-
///
128-
/// # Example
129-
///
130-
/// ```
131-
/// use ndarray::hpc::fft::wht_f32;
132-
///
133-
/// let mut data = vec![1.0f32, 0.0, 0.0, 0.0];
134-
/// wht_f32(&mut data);
135-
/// // DC impulse → all bins equal 1.0
136-
/// for &v in &data { assert!((v - 1.0).abs() < 1e-6); }
137-
/// ```
138-
pub fn wht_f32(data: &mut [f32]) {
139-
let n = data.len();
140-
assert!(
141-
n.is_power_of_two(),
142-
"WHT requires power-of-two length, got {n}"
143-
);
144-
let mut h = 1;
145-
while h < n {
146-
for i in (0..n).step_by(h * 2) {
147-
for j in i..i + h {
148-
let x = data[j];
149-
let y = data[j + h];
150-
data[j] = x + y;
151-
data[j + h] = x - y;
152-
}
153-
}
154-
h *= 2;
155-
}
156-
}
157-
158119
/// Real-to-complex FFT (f32): input is n real values, output is n/2+1 complex pairs.
159120
///
160121
/// Returns interleaved complex output: [re0, im0, re1, im1, ..., re_{n/2}, im_{n/2}]
@@ -381,50 +342,4 @@ mod tests {
381342
assert!((output[0] - 10.0).abs() < 1e-4);
382343
}
383344

384-
#[test]
385-
fn test_wht_zeros() {
386-
let mut data = vec![0.0f32; 8];
387-
wht_f32(&mut data);
388-
for &v in &data {
389-
assert_eq!(v, 0.0);
390-
}
391-
}
392-
393-
#[test]
394-
fn test_wht_dc_impulse() {
395-
// [1, 0, 0, 0, ...] → all-ones
396-
let mut data = vec![0.0f32; 8];
397-
data[0] = 1.0;
398-
wht_f32(&mut data);
399-
for &v in &data {
400-
assert!((v - 1.0).abs() < 1e-6);
401-
}
402-
}
403-
404-
#[test]
405-
fn test_wht_round_trip() {
406-
// Running WHT twice scales by n; dividing by n recovers the input.
407-
let original = vec![1.0f32, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0];
408-
let mut data = original.clone();
409-
wht_f32(&mut data);
410-
wht_f32(&mut data);
411-
let n = original.len() as f32;
412-
for (a, b) in data.iter().zip(original.iter()) {
413-
assert!((a / n - b).abs() < 1e-5, "round-trip mismatch: {a} vs {b}");
414-
}
415-
}
416-
417-
#[test]
418-
fn test_wht_known_pair() {
419-
// WHT of [1, 1] = [2, 0]; WHT of [1, -1] = [0, 2]
420-
let mut a = vec![1.0f32, 1.0];
421-
wht_f32(&mut a);
422-
assert!((a[0] - 2.0).abs() < 1e-6);
423-
assert!(a[1].abs() < 1e-6);
424-
425-
let mut b = vec![1.0f32, -1.0];
426-
wht_f32(&mut b);
427-
assert!(b[0].abs() < 1e-6);
428-
assert!((b[1] - 2.0).abs() < 1e-6);
429-
}
430345
}

0 commit comments

Comments
 (0)