a | b/src/fftn.h | ||
---|---|---|---|

1 | /*--------------------------------*-C-*---------------------------------* |
||

2 | * File: |
||

3 | * fftn.h |
||

4 | * |
||

5 | * Singleton's multivariate complex Fourier transform, computed in |
||

6 | * place using mixed-radix Fast Fourier Transform algorithm. |
||

7 | * |
||

8 | * Called here `fftn' since it does a radix-n FFT on n-dimensional data |
||

9 | * |
||

10 | * Copyright(c)1995,97 Mark Olesen <olesen@me.QueensU.CA> |
||

11 | * Queen's Univ at Kingston (Canada) |
||

12 | * |
||

13 | * Permission to use, copy, modify, and distribute this software for |
||

14 | * any purpose without fee is hereby granted, provided that this |
||

15 | * entire notice is included in all copies of any software which is |
||

16 | * or includes a copy or modification of this software and in all |
||

17 | * copies of the supporting documentation for such software. |
||

18 | * |
||

19 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR |
||

20 | * IMPLIED WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR QUEEN'S |
||

21 | * UNIVERSITY AT KINGSTON MAKES ANY REPRESENTATION OR WARRANTY OF ANY |
||

22 | * KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS |
||

23 | * FITNESS FOR ANY PARTICULAR PURPOSE. |
||

24 | * |
||

25 | * All of which is to say that you can do what you like with this |
||

26 | * source code provided you don't try to sell it as your own and you |
||

27 | * include an unaltered copy of this message (including the |
||

28 | * copyright). |
||

29 | * |
||

30 | * It is also implicitly understood that bug fixes and improvements |
||

31 | * should make their way back to the general Internet community so |
||

32 | * that everyone benefits. |
||

33 | * |
||

34 | * Brief overview of parameters: |
||

35 | * ---------------------------------------------------------------------* |
||

36 | * Re[]: real value array |
||

37 | * Im[]: imaginary value array |
||

38 | * nTotal: total number of complex values |
||

39 | * nPass: number of elements involved in this pass of transform |
||

40 | * nSpan: nspan/nPass = number of bytes to increment pointer |
||

41 | * in Re[] and Im[] |
||

42 | * isign: exponent: +1 = forward -1 = reverse |
||

43 | * scaling: normalizing constant by which the final result is DIVIDED |
||

44 | * scaling == -1, normalize by total dimension of the transform |
||

45 | * scaling < -1, normalize by the square-root of the total dimension |
||

46 | * |
||

47 | * |
||

48 | * Slightly more detailed information: |
||

49 | * ----------------------------------------------------------------------* |
||

50 | * void fft_free (void); |
||

51 | * |
||

52 | * free-up allocated temporary storage after finished all the Fourier |
||

53 | * transforms. |
||

54 | * |
||

55 | * ----------------------------------------------------------------------* |
||

56 | * |
||

57 | * int fftn (int ndim, const int dims[], REAL Re[], REAL Im[], |
||

58 | * int iSign, double scaling); |
||

59 | * |
||

60 | * NDIM = the total number dimensions |
||

61 | * DIMS = a vector of array sizes |
||

62 | * if NDIM is zero then DIMS must be zero-terminated |
||

63 | * |
||

64 | * RE and IM hold the real and imaginary components of the data, and |
||

65 | * return the resulting real and imaginary Fourier coefficients. |
||

66 | * Multidimensional data *must* be allocated contiguously. There is |
||

67 | * no limit on the number of dimensions. |
||

68 | * |
||

69 | * ISIGN = the sign of the complex exponential |
||

70 | * (ie, forward or inverse FFT) |
||

71 | * the magnitude of ISIGN (normally 1) is used to determine |
||

72 | * the correct indexing increment (see below). |
||

73 | * |
||

74 | * SCALING = normalizing constant by which the final result is DIVIDED |
||

75 | * if SCALING == -1, normalize by total dimension of the transform |
||

76 | * if SCALING < -1, normalize by the square-root of the total dimension |
||

77 | * |
||

78 | * example: |
||

79 | * tri-variate transform with Re[n3][n2][n1], Im[n3][n2][n1] |
||

80 | * |
||

81 | * int dims[3] = {n1,n2,n3} |
||

82 | * fftn (3, dims, Re, Im, 1, scaling); |
||

83 | * |
||

84 | * or, using a null terminated dimension list |
||

85 | * int dims[4] = {n1,n2,n3,0} |
||

86 | * fftn (0, dims, Re, Im, 1, scaling); |
||

87 | * ----------------------------------------------------------------------*/ |
||

88 | #ifndef _FFTN_H |
||

89 | #define _FFTN_H |
||

90 | #ifdef __cplusplus |
||

91 | extern "C" { |
||

92 | #endif |
||

93 | extern void fft_free (void); |
||

94 | |||

95 | /* double precision routine */ |
||

96 | extern int fftn (int /* ndim */, |
||

97 | const int /* dims */[], |
||

98 | double /* Re */[], |
||

99 | double /* Im */[], |
||

100 | int /* isign */, |
||

101 | double /* scaling */); |
||

102 | |||

103 | /* float precision routine */ |
||

104 | extern int fftnf (int /* ndim */, |
||

105 | const int /* dims */[], |
||

106 | float /* Re */[], |
||

107 | float /* Im */[], |
||

108 | int /* isign */, |
||

109 | double /* scaling */); |
||

110 | |||

111 | #ifdef __cplusplus |
||

112 | } |
||

113 | #endif |
||

114 | #endif /* _FFTN_H */ |
||

115 | /*----------------------- end-of-file (C header) -----------------------*/ |
||

116 | |||

117 |