pub fn dct<T>(
x: &[T],
dcttype: Option<DCTType>,
norm: Option<&str>,
) -> Result<Vec<f64>, FFTError>Expand description
Compute the 1-dimensional discrete cosine transform.
§Arguments
x- Input arraydct_type- Type of DCT to perform (default: Type2)norm- Normalization mode (None, “ortho”)
§Returns
- The DCT of the input array
§Examples
use scirs2_fft::{dct, DCTType};
// Generate a simple signal
let signal = vec![1.0, 2.0, 3.0, 4.0];
// Compute DCT-II of the signal
let dct_coeffs = dct(&signal, Some(DCTType::Type2), Some("ortho")).expect("Operation failed");
// The DC component (mean of the signal) is enhanced in DCT
let mean = 2.5; // (1+2+3+4)/4
assert!((dct_coeffs[0] / 2.0 - mean).abs() < 1e-10);§Errors
Returns an error if the input values cannot be converted to f64, or if other
computation errors occur (e.g., invalid array dimensions).