mrrs 0.1.0

Mulitrate Signal Processing
Documentation
use crate::get_hb_filter;
use crate::naive::triband::triband_cascade_noalloc;
use ndarray::{ArrayView2, ArrayViewMut2};
use num_complex::Complex;

#[no_mangle]
/// C wrapper to allow access to the triband_cascade primitive
///
/// Never use this function from rust. This is purely a C wrapper
///
/// # Safety
/// - `inp_ptr` must be valid for `inp_rows * inp_cols` reads.
/// - `out_ptr` must be valid for `out_rows * out_cols` writes.
/// - Memory must be properly aligned for `Complex<f32>`.
/// - Shapes must match the expected dimensions.
pub unsafe extern "C" fn triband_cascade(
    inp_ptr: *const Complex<f32>,
    inp_rows: usize,
    inp_cols: usize,
    out_ptr: *mut Complex<f32>,
    out_rows: usize,
    out_cols: usize,
) {
    let inp_slice = std::slice::from_raw_parts(inp_ptr, inp_rows * inp_cols);
    let out_slice = std::slice::from_raw_parts_mut(out_ptr, out_rows * out_cols);
    let inp_view = ArrayView2::from_shape((inp_rows, inp_cols), inp_slice)
        .expect("Invalid shape for input array");
    let out_view = ArrayViewMut2::from_shape((out_rows, out_cols), out_slice)
        .expect("Invalid shape for output array");
    triband_cascade_noalloc(inp_view, out_view, &get_hb_filter::<f32>(31));
}