input array
DCT transformed 1-d array
compare with scipy.fftpack.dct
1 import mir.ndslice; 2 import numir.testing : approxEqual; 3 auto y = dct([4.0, 3.0, 5.0, 10.0].sliced); 4 // python: scipy.fftpack.dct([4., 3., 5., 10.], type=2, norm="ortho") 5 assert(approxEqual([11. , -4.46088499, 3. , -0.31702534].sliced, y.slice));
Computes type-II DCT on 1-d signal:
y[k] = 2 f \sum_{n=0}^{N-1} x[n] \cos \pi k \frac{2n + 1}{2 N} ,
where the scaling factor f = sqrt(1 / 4 N) if k = 0, f = sqrt(1 / 2 N) otherwise,