← back to inhesrom__signal-kit.rs

Function bodies 301 total

All specs Real LLM only Function bodies
div function · rust · L586-L594 (9 LOC)
src/vector_simd.rs
    fn div(self, rhs: Self) -> Self::Output {
        use simd_config::F32Batch;
        self.process_simd_batches::<F32Batch>(
            rhs,
            |a, b| SimdBatch::div(a, b),
            |a, b| a / b,
        )
    }
add function · rust · L600-L608 (9 LOC)
src/vector_simd.rs
    fn add(self, rhs: f32) -> Self::Output {
        use simd_config::F32Batch;
        self.process_simd_batches_scalar::<F32Batch>(
            rhs,
            |a, b| SimdBatch::add(a, b),
            |a, b| a + b,
        )
    }
add function · rust · L613-L621 (9 LOC)
src/vector_simd.rs
    fn add(self, rhs: f32) -> Self::Output {
        use simd_config::F32Batch;
        self.process_simd_batches_scalar::<F32Batch>(
            rhs,
            |a, b| SimdBatch::add(a, b),
            |a, b| a + b,
        )
    }
sub function · rust · L626-L634 (9 LOC)
src/vector_simd.rs
    fn sub(self, rhs: f32) -> Self::Output {
        use simd_config::F32Batch;
        self.process_simd_batches_scalar::<F32Batch>(
            rhs,
            |a, b| SimdBatch::sub(a, b),
            |a, b| a - b,
        )
    }
sub function · rust · L639-L647 (9 LOC)
src/vector_simd.rs
    fn sub(self, rhs: f32) -> Self::Output {
        use simd_config::F32Batch;
        self.process_simd_batches_scalar::<F32Batch>(
            rhs,
            |a, b| SimdBatch::sub(a, b),
            |a, b| a - b,
        )
    }
mul function · rust · L652-L660 (9 LOC)
src/vector_simd.rs
    fn mul(self, rhs: f32) -> Self::Output {
        use simd_config::F32Batch;
        self.process_simd_batches_scalar::<F32Batch>(
            rhs,
            |a, b| SimdBatch::mul(a, b),
            |a, b| a * b,
        )
    }
mul function · rust · L665-L673 (9 LOC)
src/vector_simd.rs
    fn mul(self, rhs: f32) -> Self::Output {
        use simd_config::F32Batch;
        self.process_simd_batches_scalar::<F32Batch>(
            rhs,
            |a, b| SimdBatch::mul(a, b),
            |a, b| a * b,
        )
    }
Repobility · open methodology · https://repobility.com/research/
div function · rust · L678-L686 (9 LOC)
src/vector_simd.rs
    fn div(self, rhs: f32) -> Self::Output {
        use simd_config::F32Batch;
        self.process_simd_batches_scalar::<F32Batch>(
            rhs,
            |a, b| SimdBatch::div(a, b),
            |a, b| a / b,
        )
    }
div function · rust · L691-L699 (9 LOC)
src/vector_simd.rs
    fn div(self, rhs: f32) -> Self::Output {
        use simd_config::F32Batch;
        self.process_simd_batches_scalar::<F32Batch>(
            rhs,
            |a, b| SimdBatch::div(a, b),
            |a, b| a / b,
        )
    }
add_assign function · rust · L704-L711 (8 LOC)
src/vector_simd.rs
    fn add_assign(&mut self, rhs: f32) {
        use simd_config::F32Batch;
        self.process_simd_batches_scalar_inplace::<F32Batch>(
            rhs,
            |a, b| SimdBatch::add(a, b),
            |a, b| a + b,
        );
    }
sub_assign function · rust · L715-L722 (8 LOC)
src/vector_simd.rs
    fn sub_assign(&mut self, rhs: f32) {
        use simd_config::F32Batch;
        self.process_simd_batches_scalar_inplace::<F32Batch>(
            rhs,
            |a, b| SimdBatch::sub(a, b),
            |a, b| a - b,
        );
    }
mul_assign function · rust · L726-L733 (8 LOC)
src/vector_simd.rs
    fn mul_assign(&mut self, rhs: f32) {
        use simd_config::F32Batch;
        self.process_simd_batches_scalar_inplace::<F32Batch>(
            rhs,
            |a, b| SimdBatch::mul(a, b),
            |a, b| a * b,
        );
    }
div_assign function · rust · L737-L744 (8 LOC)
src/vector_simd.rs
    fn div_assign(&mut self, rhs: f32) {
        use simd_config::F32Batch;
        self.process_simd_batches_scalar_inplace::<F32Batch>(
            rhs,
            |a, b| SimdBatch::div(a, b),
            |a, b| a / b,
        );
    }
abs function · rust · L750-L777 (28 LOC)
src/vector_simd.rs
    pub fn abs(&self) -> VectorSimd<f32> {
        use simd_config::F32Batch;

        // Allocate without initialization for better performance
        let mut result = Vec::with_capacity(self.len());
        unsafe {
            result.set_len(self.len());
        }

        let lanes = F32Batch::LANES;
        let simd_end = (self.len() / lanes) * lanes;

        // Process SIMD batches using zero-copy cast_slice
        let a_simd: &[F32Batch] = cast_slice(&self.data[..simd_end]);
        let result_simd: &mut [F32Batch] = cast_slice_mut(&mut result[..simd_end]);

        // Use iterator-based approach for better optimization
        result_simd.iter_mut()
            .zip(a_simd.iter())
            .for_each(|(r, a)| *r = a.abs());

        // Process remainder
        for i in simd_end..self.len() {
            result[i] = self.data[i].abs();
        }

        VectorSimd { data: result }
    }
convolve_simple function · rust · L780-L797 (18 LOC)
src/vector_simd.rs
    pub fn convolve_simple(&self, kernel: &VectorSimd<f32>) -> VectorSimd<f32> {
        if kernel.size() > self.size() {
            return VectorSimd::new();
        }

        let output_size = self.size() - kernel.size() + 1;
        let mut result = vec![0.0f32; output_size];

        for i in 0..output_size {
            let mut sum = 0.0f32;
            for j in 0..kernel.size() {
                sum += self.data[i + j] * kernel.data[j];
            }
            result[i] = sum;
        }

        VectorSimd { data: result }
    }
Repobility · code-quality intelligence · https://repobility.com
convolve function · rust · L800-L840 (41 LOC)
src/vector_simd.rs
    pub fn convolve(&self, kernel: &VectorSimd<f32>) -> VectorSimd<f32> {
        if kernel.size() > self.size() {
            return VectorSimd::new();
        }

        use simd_config::F32Batch;
        const LANES: usize = 4; // f32x4

        let output_size = self.size() - kernel.size() + 1;
        let mut result = vec![0.0f32; output_size];

        let simd_chunks = output_size / LANES;

        // Process LANES output samples at a time
        for chunk_idx in 0..simd_chunks {
            let base_idx = chunk_idx * LANES;
            let mut accum = F32Batch::zero();

            // For each kernel tap (using load since base_idx + k may not be aligned)
            for k in 0..kernel.size() {
                let sig = F32Batch::load(&self.data[base_idx + k..]);
                let kern = F32Batch::splat(kernel.data[k]);
                accum = SimdBatch::add(accum, SimdBatch::mul(sig, kern));
            }

            // Use cast_slice_mut for zero-copy store (base_idx is al
linspace function · rust · L849-L862 (14 LOC)
src/vector_simd.rs
    pub fn linspace(start: f64, stop: f64, length: usize) -> Self {
        if length == 0 {
            return Self::new();
        }
        if length == 1 {
            return Self::from_vec(vec![start]);
        }

        let step = (stop - start) / (length as f64 - 1.0);
        let data: Vec<f64> = (0..length)
            .map(|i| start + (i as f64) * step)
            .collect();
        Self { data }
    }
add function · rust · L871-L879 (9 LOC)
src/vector_simd.rs
    fn add(self, rhs: Self) -> Self::Output {
        use simd_config::F64Batch;
        self.process_simd_batches::<F64Batch>(
            &rhs,
            |a, b| SimdBatch::add(a, b),
            |a, b| a + b,
        )
    }
add function · rust · L884-L892 (9 LOC)
src/vector_simd.rs
    fn add(self, rhs: Self) -> Self::Output {
        use simd_config::F64Batch;
        self.process_simd_batches::<F64Batch>(
            rhs,
            |a, b| SimdBatch::add(a, b),
            |a, b| a + b,
        )
    }
mul function · rust · L897-L905 (9 LOC)
src/vector_simd.rs
    fn mul(self, rhs: Self) -> Self::Output {
        use simd_config::F64Batch;
        self.process_simd_batches::<F64Batch>(
            &rhs,
            |a, b| SimdBatch::mul(a, b),
            |a, b| a * b,
        )
    }
mul function · rust · L910-L918 (9 LOC)
src/vector_simd.rs
    fn mul(self, rhs: Self) -> Self::Output {
        use simd_config::F64Batch;
        self.process_simd_batches::<F64Batch>(
            rhs,
            |a, b| SimdBatch::mul(a, b),
            |a, b| a * b,
        )
    }
div_assign function · rust · L922-L929 (8 LOC)
src/vector_simd.rs
    fn div_assign(&mut self, rhs: f64) {
        use simd_config::F64Batch;
        self.process_simd_batches_scalar_inplace::<F64Batch>(
            rhs,
            |a, b| SimdBatch::div(a, b),
            |a, b| a / b,
        );
    }
add_optimized function · rust · L959-L974 (16 LOC)
src/vector_simd.rs
    fn add_optimized(&self, other: &VectorSimd<Complex<f32>>) -> VectorSimd<Complex<f32>> {
        assert_eq!(self.len(), other.len());

        // Allocate without initialization for better performance
        let mut result = Vec::with_capacity(self.len());
        unsafe {
            result.set_len(self.len());
        }

        // Simple loop - LLVM will auto-vectorize this
        for i in 0..self.len() {
            result[i] = self.data[i] + other.data[i];
        }

        VectorSimd { data: result }
    }
If a scraper extracted this row, it came from Repobility (https://repobility.com)
mul_optimized function · rust · L977-L992 (16 LOC)
src/vector_simd.rs
    fn mul_optimized(&self, other: &VectorSimd<Complex<f32>>) -> VectorSimd<Complex<f32>> {
        assert_eq!(self.len(), other.len());

        // Allocate without initialization
        let mut result = Vec::with_capacity(self.len());
        unsafe {
            result.set_len(self.len());
        }

        // Simple loop - LLVM will auto-vectorize complex multiplication
        for i in 0..self.len() {
            result[i] = self.data[i] * other.data[i];
        }

        VectorSimd { data: result }
    }
sub_optimized function · rust · L995-L1008 (14 LOC)
src/vector_simd.rs
    fn sub_optimized(&self, other: &VectorSimd<Complex<f32>>) -> VectorSimd<Complex<f32>> {
        assert_eq!(self.len(), other.len());

        let mut result = Vec::with_capacity(self.len());
        unsafe {
            result.set_len(self.len());
        }

        for i in 0..self.len() {
            result[i] = self.data[i] - other.data[i];
        }

        VectorSimd { data: result }
    }
div_optimized function · rust · L1011-L1024 (14 LOC)
src/vector_simd.rs
    fn div_optimized(&self, other: &VectorSimd<Complex<f32>>) -> VectorSimd<Complex<f32>> {
        assert_eq!(self.len(), other.len());

        let mut result = Vec::with_capacity(self.len());
        unsafe {
            result.set_len(self.len());
        }

        for i in 0..self.len() {
            result[i] = self.data[i] / other.data[i];
        }

        VectorSimd { data: result }
    }
convolve function · rust · L1095-L1160 (66 LOC)
src/vector_simd.rs
    pub fn convolve(&self, kernel: &VectorSimd<Complex<f32>>) -> VectorSimd<Complex<f32>> {
        if kernel.size() > self.size() {
            return VectorSimd::new();
        }

        use simd_config::F32Batch;
        const LANES: usize = 2; // 2 complex numbers per f32x4

        let output_size = self.size() - kernel.size() + 1;
        let mut result = vec![Complex::new(0.0, 0.0); output_size];

        let simd_chunks = output_size / LANES;

        // Process LANES output samples at a time
        for chunk_idx in 0..simd_chunks {
            let base_idx = chunk_idx * LANES;
            let mut accum = F32Batch::from([0.0, 0.0, 0.0, 0.0]);

            // For each kernel tap
            for k in 0..kernel.size() {
                // Load 2 complex signal values - SAFETY: Complex<f32> has repr(C) layout
                let sig_floats: &[f32] = unsafe {
                    std::slice::from_raw_parts(
                        self.data[base_idx + k..].as_ptr() as *const f32,
 
test_f32_add function · rust · L1172-L1180 (9 LOC)
src/vector_simd.rs
    fn test_f32_add() {
        let a = VectorSimd::from_vec(vec![1.0f32, 2.0, 3.0, 4.0, 5.0]);
        let b = VectorSimd::from_vec(vec![5.0f32, 6.0, 7.0, 8.0, 9.0]);

        let c = &a + &b;
        assert_eq!(c[0], 6.0);
        assert_eq!(c[1], 8.0);
        assert_eq!(c[4], 14.0);
    }
test_f32_mul_scalar function · rust · L1183-L1189 (7 LOC)
src/vector_simd.rs
    fn test_f32_mul_scalar() {
        let a = VectorSimd::from_vec(vec![1.0f32, 2.0, 3.0, 4.0]);
        let b = &a * 2.0;

        assert_eq!(b[0], 2.0);
        assert_eq!(b[3], 8.0);
    }
test_f32_div_assign function · rust · L1192-L1199 (8 LOC)
src/vector_simd.rs
    fn test_f32_div_assign() {
        let mut v = VectorSimd::from_vec(vec![10.0f32, 20.0, 30.0]);
        v /= 2.0;

        assert_eq!(v[0], 5.0);
        assert_eq!(v[1], 10.0);
        assert_eq!(v[2], 15.0);
    }
test_complex_operations function · rust · L1202-L1216 (15 LOC)
src/vector_simd.rs
    fn test_complex_operations() {
        let a = VectorSimd::from_vec(vec![
            Complex::new(2.0f32, 3.0),
            Complex::new(4.0, 5.0),
        ]);
        let b = VectorSimd::from_vec(vec![
            Complex::new(4.0f32, 5.0),
            Complex::new(6.0, 7.0),
        ]);

        let c = &a * &b;
        // (2+3i) * (4+5i) = 8 + 10i + 12i + 15i² = 8 + 22i - 15 = -7 + 22i
        assert_eq!(c[0].re, -7.0);
        assert_eq!(c[0].im, 22.0);
    }
Repobility analyzer · published findings · https://repobility.com
test_f32_abs function · rust · L1219-L1228 (10 LOC)
src/vector_simd.rs
    fn test_f32_abs() {
        let a = VectorSimd::from_vec(vec![-1.0f32, 2.0, -3.0, 4.0, -5.0]);
        let b = a.abs();

        assert_eq!(b[0], 1.0);
        assert_eq!(b[1], 2.0);
        assert_eq!(b[2], 3.0);
        assert_eq!(b[3], 4.0);
        assert_eq!(b[4], 5.0);
    }
test_f32_linspace function · rust · L1231-L1238 (8 LOC)
src/vector_simd.rs
    fn test_f32_linspace() {
        let v = VectorSimd::<f32>::linspace(0.0, 10.0, 11);

        assert_eq!(v.len(), 11);
        assert_eq!(v[0], 0.0);
        assert_eq!(v[10], 10.0);
        assert!((v[5] - 5.0).abs() < 1e-6);
    }
test_convolution function · rust · L1241-L1251 (11 LOC)
src/vector_simd.rs
    fn test_convolution() {
        let signal = VectorSimd::from_vec((0..1024).map(|x| x as f32).collect::<Vec<_>>());
        let kernel = VectorSimd::from_vec(vec![1.0f32, 0.0, 1.0]);

        let result = signal.convolve(&kernel);

        // First element should be signal[0] + signal[2] = 0 + 2 = 2
        assert_eq!(result[0], 2.0);
        // Second element should be signal[1] + signal[3] = 1 + 3 = 4
        assert_eq!(result[1], 4.0);
    }
scalar_add_f32_no_vec function · rust · L1267-L1274 (8 LOC)
src/vector_simd.rs
    fn scalar_add_f32_no_vec(a: &[f32], b: &[f32]) -> Vec<f32> {
        let mut result = Vec::with_capacity(a.len());
        for i in 0..a.len() {
            // black_box prevents the compiler from optimizing this loop
            result.push(std::hint::black_box(a[i] + b[i]));
        }
        result
    }
scalar_mul_f32_no_vec function · rust · L1283-L1289 (7 LOC)
src/vector_simd.rs
    fn scalar_mul_f32_no_vec(a: &[f32], b: &[f32]) -> Vec<f32> {
        let mut result = Vec::with_capacity(a.len());
        for i in 0..a.len() {
            result.push(std::hint::black_box(a[i] * b[i]));
        }
        result
    }
scalar_convolve_f32 function · rust · L1292-L1304 (13 LOC)
src/vector_simd.rs
    fn scalar_convolve_f32(signal: &[f32], kernel: &[f32]) -> Vec<f32> {
        let output_size = signal.len() - kernel.len() + 1;
        let mut result = vec![0.0f32; output_size];

        for i in 0..output_size {
            let mut sum = 0.0f32;
            for j in 0..kernel.len() {
                sum += signal[i + j] * kernel[j];
            }
            result[i] = sum;
        }
        result
    }
benchmark_f32_addition function · rust · L1307-L1345 (39 LOC)
src/vector_simd.rs
    fn benchmark_f32_addition() {
        println!("\n=== Benchmark: f32 Addition ===");

        for &size in &[10_000, 100_000] {
            println!("\nVector size: {}", size);

            let data_a: Vec<f32> = (0..size).map(|i| (i % 1000) as f32).collect();
            let data_b: Vec<f32> = (0..size).map(|i| ((i * 7) % 1000) as f32).collect();

            let vec_a = VectorSimd::from_vec(data_a.clone());
            let vec_b = VectorSimd::from_vec(data_b.clone());

            const ITERATIONS: usize = 10;

            // Benchmark SIMD
            let start = Instant::now();
            let mut simd_result = VectorSimd::new();
            for _ in 0..ITERATIONS {
                simd_result = &vec_a + &vec_b;
            }
            let simd_time = start.elapsed() / ITERATIONS as u32;
            std::hint::black_box(&simd_result); // Prevent optimization

            // Benchmark Scalar
            let start = Instant::now();
            let mut scalar_result = Vec::new()
benchmark_f32_multiplication function · rust · L1348-L1386 (39 LOC)
src/vector_simd.rs
    fn benchmark_f32_multiplication() {
        println!("\n=== Benchmark: f32 Multiplication ===");

        for &size in &[10_000, 100_000] {
            println!("\nVector size: {}", size);

            let data_a: Vec<f32> = (0..size).map(|i| (i % 1000) as f32 / 1000.0).collect();
            let data_b: Vec<f32> = (0..size).map(|i| ((i * 7) % 1000) as f32 / 1000.0).collect();

            let vec_a = VectorSimd::from_vec(data_a.clone());
            let vec_b = VectorSimd::from_vec(data_b.clone());

            const ITERATIONS: usize = 10;

            // Benchmark SIMD
            let start = Instant::now();
            let mut simd_result = VectorSimd::new();
            for _ in 0..ITERATIONS {
                simd_result = &vec_a * &vec_b;
            }
            let simd_time = start.elapsed() / ITERATIONS as u32;
            std::hint::black_box(&simd_result);

            // Benchmark Scalar
            let start = Instant::now();
            let mut scalar_result = Vec:
Repobility · open methodology · https://repobility.com/research/
benchmark_f32_scalar_multiply function · rust · L1389-L1425 (37 LOC)
src/vector_simd.rs
    fn benchmark_f32_scalar_multiply() {
        println!("\n=== Benchmark: f32 Scalar Multiply (vec * scalar) ===");

        for &size in &[10_000, 100_000] {
            println!("\nVector size: {}", size);

            let data: Vec<f32> = (0..size).map(|i| (i % 1000) as f32 / 1000.0).collect();
            let vec = VectorSimd::from_vec(data.clone());
            let scalar = 2.5f32;

            const ITERATIONS: usize = 10;

            // Benchmark SIMD
            let start = Instant::now();
            let mut simd_result = VectorSimd::new();
            for _ in 0..ITERATIONS {
                simd_result = &vec * scalar;
            }
            let simd_time = start.elapsed() / ITERATIONS as u32;
            std::hint::black_box(&simd_result);

            // Benchmark Scalar
            let start = Instant::now();
            let mut scalar_result = Vec::new();
            for _ in 0..ITERATIONS {
                scalar_result = data.iter().map(|&x| x * scalar).collect()
benchmark_f32_division function · rust · L1428-L1466 (39 LOC)
src/vector_simd.rs
    fn benchmark_f32_division() {
        println!("\n=== Benchmark: f32 Division ===");

        for &size in &[10_000, 100_000] {
            println!("\nVector size: {}", size);

            let data_a: Vec<f32> = (0..size).map(|i| (i % 1000) as f32 + 1.0).collect();
            let data_b: Vec<f32> = (0..size).map(|i| ((i * 7) % 1000) as f32 + 1.0).collect();

            let vec_a = VectorSimd::from_vec(data_a.clone());
            let vec_b = VectorSimd::from_vec(data_b.clone());

            const ITERATIONS: usize = 10;

            // Benchmark SIMD
            let start = Instant::now();
            let mut simd_result = VectorSimd::new();
            for _ in 0..ITERATIONS {
                simd_result = &vec_a / &vec_b;
            }
            let simd_time = start.elapsed() / ITERATIONS as u32;
            std::hint::black_box(&simd_result);

            // Benchmark Scalar
            let start = Instant::now();
            let mut scalar_result = Vec::new();
          
benchmark_f32_abs function · rust · L1469-L1504 (36 LOC)
src/vector_simd.rs
    fn benchmark_f32_abs() {
        println!("\n=== Benchmark: f32 Absolute Value ===");

        for &size in &[10_000, 100_000] {
            println!("\nVector size: {}", size);

            let data: Vec<f32> = (0..size).map(|i| if i % 2 == 0 { i as f32 } else { -(i as f32) }).collect();
            let vec = VectorSimd::from_vec(data.clone());

            const ITERATIONS: usize = 10;

            // Benchmark SIMD
            let start = Instant::now();
            let mut simd_result = VectorSimd::new();
            for _ in 0..ITERATIONS {
                simd_result = vec.abs();
            }
            let simd_time = start.elapsed() / ITERATIONS as u32;
            std::hint::black_box(&simd_result);

            // Benchmark Scalar
            let start = Instant::now();
            let mut scalar_result = Vec::new();
            for _ in 0..ITERATIONS {
                scalar_result = data.iter().map(|&x| x.abs()).collect();
            }
            let scalar_time = s
benchmark_f32_convolution function · rust · L1507-L1545 (39 LOC)
src/vector_simd.rs
    fn benchmark_f32_convolution() {
        println!("\n=== Benchmark: f32 Convolution ===");

        for &size in &[10_000, 100_000] {
            println!("\nSignal size: {}, Kernel size: 101", size);

            let signal_data: Vec<f32> = (0..size).map(|i| (i % 1000) as f32 / 1000.0).collect();
            let kernel_data: Vec<f32> = (0..101).map(|i| (i as f32 / 100.0).sin()).collect();

            let signal = VectorSimd::from_vec(signal_data.clone());
            let kernel = VectorSimd::from_vec(kernel_data.clone());

            const ITERATIONS: usize = 10;

            // Benchmark SIMD
            let start = Instant::now();
            let mut simd_result = VectorSimd::new();
            for _ in 0..ITERATIONS {
                simd_result = signal.convolve(&kernel);
            }
            let simd_time = start.elapsed() / ITERATIONS as u32;
            std::hint::black_box(&simd_result);

            // Benchmark Scalar
            let start = Instant::now();
      
scalar_complex_mul_no_vec function · rust · L1549-L1555 (7 LOC)
src/vector_simd.rs
    fn scalar_complex_mul_no_vec(a: &[Complex<f32>], b: &[Complex<f32>]) -> Vec<Complex<f32>> {
        let mut result = Vec::with_capacity(a.len());
        for i in 0..a.len() {
            result.push(std::hint::black_box(a[i] * b[i]));
        }
        result
    }
scalar_complex_add_no_vec function · rust · L1559-L1565 (7 LOC)
src/vector_simd.rs
    fn scalar_complex_add_no_vec(a: &[Complex<f32>], b: &[Complex<f32>]) -> Vec<Complex<f32>> {
        let mut result = Vec::with_capacity(a.len());
        for i in 0..a.len() {
            result.push(std::hint::black_box(a[i] + b[i]));
        }
        result
    }
benchmark_complex32_addition function · rust · L1568-L1622 (55 LOC)
src/vector_simd.rs
    fn benchmark_complex32_addition() {
        println!("\n=== Benchmark: Complex32 Addition ===");

        for &size in &[1_000_000] {
            println!("\nVector size: {}", size);

            let data_a: Vec<Complex<f32>> = (0..size)
                .map(|i| Complex::new((i % 100) as f32 / 100.0, ((i * 3) % 100) as f32 / 100.0))
                .collect();
            let data_b: Vec<Complex<f32>> = (0..size)
                .map(|i| Complex::new(((i * 7) % 100) as f32 / 100.0, ((i * 11) % 100) as f32 / 100.0))
                .collect();

            let vec_a = VectorSimd::from_vec(data_a.clone());
            let vec_b = VectorSimd::from_vec(data_b.clone());

            const ITERATIONS: usize = 10;

            // Benchmark SIMD
            let start = Instant::now();
            let mut simd_result = VectorSimd::new();
            for _ in 0..ITERATIONS {
                simd_result = &vec_a + &vec_b;
            }
            let simd_time = start.elapsed() / ITERATIONS 
benchmark_complex32_multiplication function · rust · L1625-L1679 (55 LOC)
src/vector_simd.rs
    fn benchmark_complex32_multiplication() {
        println!("\n=== Benchmark: Complex32 Multiplication ===");

        for &size in &[1_000_000] {
            println!("\nVector size: {}", size);

            let data_a: Vec<Complex<f32>> = (0..size)
                .map(|i| Complex::new((i % 100) as f32 / 100.0, ((i * 3) % 100) as f32 / 100.0))
                .collect();
            let data_b: Vec<Complex<f32>> = (0..size)
                .map(|i| Complex::new(((i * 7) % 100) as f32 / 100.0, ((i * 11) % 100) as f32 / 100.0))
                .collect();

            let vec_a = VectorSimd::from_vec(data_a.clone());
            let vec_b = VectorSimd::from_vec(data_b.clone());

            const ITERATIONS: usize = 10;

            // Benchmark SIMD
            let start = Instant::now();
            let mut simd_result = VectorSimd::new();
            for _ in 0..ITERATIONS {
                simd_result = &vec_a * &vec_b;
            }
            let simd_time = start.elapsed() /
Repobility · code-quality intelligence · https://repobility.com
benchmark_complex32_division function · rust · L1682-L1724 (43 LOC)
src/vector_simd.rs
    fn benchmark_complex32_division() {
        println!("\n=== Benchmark: Complex32 Division ===");

        for &size in &[1_000_000] {
            println!("\nVector size: {}", size);

            let data_a: Vec<Complex<f32>> = (0..size)
                .map(|i| Complex::new((i % 100) as f32 / 100.0 + 1.0, ((i * 3) % 100) as f32 / 100.0 + 1.0))
                .collect();
            let data_b: Vec<Complex<f32>> = (0..size)
                .map(|i| Complex::new(((i * 7) % 100) as f32 / 100.0 + 1.0, ((i * 11) % 100) as f32 / 100.0 + 1.0))
                .collect();

            let vec_a = VectorSimd::from_vec(data_a.clone());
            let vec_b = VectorSimd::from_vec(data_b.clone());

            const ITERATIONS: usize = 10;

            // Benchmark SIMD
            let start = Instant::now();
            let mut simd_result = VectorSimd::new();
            for _ in 0..ITERATIONS {
                simd_result = &vec_a / &vec_b;
            }
            let simd_time = start
benchmark_complex32_convolution function · rust · L1727-L1778 (52 LOC)
src/vector_simd.rs
    fn benchmark_complex32_convolution() {
        println!("\n=== Benchmark: Complex32 Convolution ===");

        for &size in &[1_000_000] {
            println!("\nSignal size: {}, Kernel size: 101", size);

            let signal_data: Vec<Complex<f32>> = (0..size)
                .map(|i| Complex::new((i % 1000) as f32 / 1000.0, ((i * 3) % 1000) as f32 / 1000.0))
                .collect();
            let kernel_data: Vec<Complex<f32>> = (0..101)
                .map(|i| Complex::new((i as f32 / 100.0).sin(), (i as f32 / 100.0).cos()))
                .collect();

            let signal = VectorSimd::from_vec(signal_data.clone());
            let kernel = VectorSimd::from_vec(kernel_data.clone());

            const ITERATIONS: usize = 10;

            // Benchmark SIMD
            let start = Instant::now();
            let mut simd_result = VectorSimd::new();
            for _ in 0..ITERATIONS {
                simd_result = signal.convolve(&kernel);
            }
            
benchmark_detailed_comparison function · rust · L1781-L1868 (88 LOC)
src/vector_simd.rs
    fn benchmark_detailed_comparison() {
        println!("\n=== Detailed Performance Analysis ===");
        println!("\nComparing SIMD vs Auto-Vectorized Scalar vs Non-Vectorized Scalar");
        println!("Vector size: 100,000 elements\n");

        const SIZE: usize = 1_000_000;
        const ITERATIONS: usize = 10;

        let data_a: Vec<f32> = (0..SIZE).map(|i| (i % 1000) as f32 / 1000.0).collect();
        let data_b: Vec<f32> = (0..SIZE).map(|i| ((i * 7) % 1000) as f32 / 1000.0).collect();
        let vec_a = VectorSimd::from_vec(data_a.clone());
        let vec_b = VectorSimd::from_vec(data_b.clone());

        // === ADDITION ===
        println!("Addition (+):");

        // SIMD
        let start = Instant::now();
        let mut simd_result = VectorSimd::new();
        for _ in 0..ITERATIONS {
            simd_result = &vec_a + &vec_b;
        }
        let simd_time = start.elapsed() / ITERATIONS as u32;
        std::hint::black_box(&simd_result);

        // Auto-vecto
‹ prevpage 6 / 7next ›