annotate src/fftw-3.3.8/CONVENTIONS @ 167:bd3cc4d1df30

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