annotate src/fftw-3.3.8/CONVENTIONS @ 82:d0c2a83c1364

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