/*************************************************************************** * Copyright (C) 1994 Charles P. Peterson * * 4007 Enchanted Sun, San Antonio, Texas 78244-1254 * * Email: Charles_P_Peterson@fcircus.sat.tx.us * * * * This is free software with NO WARRANTY. * * See gfft.c, or run program itself, for details. * * Support is available for a fee. * *************************************************************************** * * Program: gfft--General FFT analysis * File: complex.h * Purpose: define structs and ops for complex numbers * Author: Charles Peterson (CPP) * History: 29-June-1993 CPP; Created. * Comment: (1) C_MULT DOES NOT ALLOW INPUT & OUTPUT TO COINCIDE * (2) MACROS DO NOT ASSUME float or double data size */ typedef struct { float real; float imaginary; } Complex_float; typedef struct { double real; double imaginary; } Complex_double; #ifndef NO_STRUCT_ASSIGN #define CF_SWAP(a,b) {Complex_float tempc=(a); (a)=(b); (b)=tempc;} #else #define CF_SWAP(a,b) {\ float tempf;\ tempf = (a).real; \ (a).real = (b).real; \ (b).real = tempf; \ tempf = (a).imaginary; \ (a).imaginary = (b).imaginary; \ (b).imaginary = tempf; \ } #endif #define C_ADD(ADDEND, ADDENDUM, SUM) \ { \ (SUM).real = (ADDEND).real + (ADDENDUM).real; \ (SUM).imaginary = (ADDEND).imaginary + (ADDENDUM).imaginary; \ } #define C_SUB(MINUEND, SUBTRAHEND, DIFFERENCE) \ { \ (DIFFERENCE).real = (MINUEND).real - (SUBTRAHEND).real; \ (DIFFERENCE).imaginary = (MINUEND).imaginary - (SUBTRAHEND).imaginary; \ } #define C_MULT(MULTIPLICAND, MULTIPLIER, PRODUCT) \ { \ (PRODUCT).real = (MULTIPLICAND).real * (MULTIPLIER).real - \ (MULTIPLICAND).imaginary * (MULTIPLIER).imaginary; \ (PRODUCT).imaginary = (MULTIPLICAND).real * (MULTIPLIER).imaginary + \ (MULTIPLICAND).imaginary * (MULTIPLIER).real; \ } /* * And now, those prototypes involving complex numbers */ void cfft (Complex_float *datac, long n, int isign); void rfft (Complex_float *datac, long n, int isign); /* input float array */