/* * Discrete trigonometric transforms based on FFT. * * Copyright (C) 1991--94 Wickerhauser Consulting. All Rights Reserved. * May be freely copied for personal, noncommercial use by owners of * ``Adapted Wavelet Analysis from Theory to Software'' ISBN 1-56881-041-5 * by Mladen Victor Wickerhauser [AK Peters, Ltd., Wellesley, Mass., 1994] */ #include #include #include #include "real.h" #include "common.h" /* For the constants SR2 and PI. */ #include "bitrev.h" /* Generic bit-reversal functions. */ #include "fft.h" #include "dtts.h" /**************************************************************** * Fill the preallocated arrays of real's `c[]' and `s[]', each * assumed to be of length `N/2', with the respective values: * c[n] = cos(n*PI/N), n=0,1,...,N/2-1. * s[n] = sin(n*PI/N), n=0,1,...,N/2-1. */ extern void mkcossin( /* Fill the arrays with: */ real *c, /* (real)cos(n*PI/N), */ real *s, /* (real)sin(n*PI/N), */ int N) /* for n=0,1,2,...,N/2-1. */ { double factor, theta; int n; factor = PI/(double)N; c[0] = (real)1.0; s[0] = (real)0.0; theta = 0.0; for(n=1; n<(N>>1); n++) { theta += factor; c[n] = (real)cos(theta); s[n] = (real)sin(theta); } return; } /**************************************************************** * dct_i() * * This function accepts an input array of N + 1 `real' elements, * for N=2^q, and replaces its elements with the DCT-I transform. * It uses the radix-2 FFT on 2^{q+1} points, using a temporary * array of 2^{q+1} extra `complex' data structs which it * allocates and frees upon termination. It is its own inverse. */ extern void dct_i( real *x, /* Input; length (1<