annotate src/fftw-3.3.3/CONVENTIONS @ 169:223a55898ab9 tip default

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