annotate fft/fftw/fftw-3.3.4/CONVENTIONS @ 40:223f770b5341 kissfft-double tip

Try a double-precision kissfft
author Chris Cannam
date Wed, 07 Sep 2016 10:40:32 +0100
parents 26056e866c29
children
rev   line source
Chris@19 1 Code conventions used internally by fftw3 (not in API):
Chris@19 2
Chris@19 3 LEARN FROM THE MASTERS: read Ken Thompson's C compiler in Plan 9.
Chris@19 4 Avoid learning from C++/Java programs.
Chris@19 5
Chris@19 6 INDENTATION: K&R, 5 spaces/tab. In case of doubt, indent -kr -i5.
Chris@19 7
Chris@19 8 NAMES: keep them short. Shorter than you think. The Bible was written
Chris@19 9 without vowels. Don't outsmart the Bible.
Chris@19 10
Chris@19 11 Common names:
Chris@19 12
Chris@19 13 R : real type, aka fftw_real
Chris@19 14 E : real type for local variables (possibly extra precision)
Chris@19 15 C : complex type
Chris@19 16 sz : size
Chris@19 17 vecsz : vector size
Chris@19 18 is, os : input/output stride
Chris@19 19 ri, ii : real/imag input (complex data)
Chris@19 20 ro, io : real/imag output (complex data)
Chris@19 21 I, O : real input/output (real data)
Chris@19 22 A : assert
Chris@19 23 CK : check
Chris@19 24 S : solver, defined internally to each solver file
Chris@19 25 P : plan, defined internally to each solver file
Chris@19 26 k : codelet
Chris@19 27 X(...) : used for mangling of external names (see below)
Chris@19 28 K(...) : floating-point constant, in E precision
Chris@19 29
Chris@19 30 If a name is used often and must have the form fftw_foo to avoid
Chris@19 31 namespace pollution, #define FOO fftw_foo and use the short name.
Chris@19 32
Chris@19 33 Leave that hungarian crap to MS. foo_t counts as hungarian: use
Chris@19 34 foo instead. foo is lowercase so that it does not look like a DOS
Chris@19 35 program. Exception: typedef struct foo_s {...} foo; instead of
Chris@19 36 typedef struct foo {...} foo; for C++ compatibility.
Chris@19 37
Chris@19 38 NAME MANGLING: use X(foo) for external names instead of fftw_foo.
Chris@19 39 X(foo) expands to fftwf_foo or fftw_foo, depending on the
Chris@19 40 precision. (Unfortunately, this is a ugly form of hungarian
Chris@19 41 notation. Grrr...) Names that are not exported do not need to be
Chris@19 42 mangled.
Chris@19 43
Chris@19 44 REPEATED CODE: favor a table. E.g., do not write
Chris@19 45
Chris@19 46 foo("xxx", 1);
Chris@19 47 foo("yyy", 2);
Chris@19 48 foo("zzz", -1);
Chris@19 49
Chris@19 50 Instead write
Chris@19 51
Chris@19 52 struct { const char *nam, int arg } footab[] = {
Chris@19 53 { "xxx", 1 },
Chris@19 54 { "yyy", 2 },
Chris@19 55 { "zzz", -1 }
Chris@19 56 };
Chris@19 57
Chris@19 58 and loop over footab. Rationale: it saves code space.
Chris@19 59 Similarly, replace a switch statement with a table whenever
Chris@19 60 possible.
Chris@19 61
Chris@19 62 C++: The code should compile as a C++ program. Run the code through
Chris@19 63 gcc -xc++ . The extra C++ restrictions are unnecessary, of
Chris@19 64 course, but this will save us from a flood of complaints when
Chris@19 65 we release the code.