# sci-gaussfilt-rs

A Rust implementation of the 1D Gaussian filter that exactly matches the behavior of `scipy.ndimage.gaussian_filter1d`.

This crate provides a high-performance, pure Rust implementation of the Gaussian filter for 1D arrays, supporting various boundary conditions and floating-point types (`f32`, `f64`). It is designed to be a drop-in replacement for SciPy's implementation in Rust applications.

## Features

*   **SciPy Parity**: Matches `scipy.ndimage.gaussian_filter1d` output within floating-point tolerance (`1e-6` or better).
*   **Boundary Modes**: Supports `Reflect`, `Nearest`, and `Constant` padding modes.
*   **Generic**: Works with `f32` and `f64` data types.
*   **Performance**: Optimized convolution with pre-calculated kernels and padding.

## Installation

Add this to your `Cargo.toml`:

```toml
[dependencies]
sci-gaussfilt-rs = "0.1.0"
```

## Usage

```rust
use sci_gaussfilt_rs::{gaussian_filter1d, types::BoundaryMode};

fn main() {
    let data = vec![1.0, 2.0, 3.0, 4.0, 5.0];
    let sigma = 1.0;
    let truncate = 4.0;
    
    // Apply Gaussian filter with Reflect boundary mode
    let result = gaussian_filter1d(&data, sigma, truncate, BoundaryMode::Reflect).unwrap();
    
    println!("Filtered data: {:?}", result);
}
```

## Supported Boundary Modes

*   `BoundaryMode::Reflect`: (Default in SciPy) `d c b a | a b c d | d c b a`
*   `BoundaryMode::Nearest`: `a a a a | a b c d | d d d d`
*   `BoundaryMode::Constant(value)`: `v v v v | a b c d | v v v v`

## License

MIT