diff options
Diffstat (limited to 'src/pair.h')
-rw-r--r-- | src/pair.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/pair.h b/src/pair.h new file mode 100644 index 0000000..baae9f5 --- /dev/null +++ b/src/pair.h @@ -0,0 +1,57 @@ +#ifndef PAIR_H +#define PAIR_H +#include "util.h" + +/* This header contains struct definitions of some pairs. */ + +/* I probably should have named the fields by numbers, such as x1, x2, + etc, so that we can recursively declare these structs by macros. + But it is not worth the trouble to rewrite this I guess. */ + +typedef NUM pair1; + +struct pair2_s { NUM x; NUM y; }; + +typedef struct pair2_s pair2; + +struct pair3_s { NUM x; NUM y; NUM z; }; + +typedef struct pair3_s pair3; + +struct pair4_s { NUM x; NUM y; NUM z; NUM u; }; + +typedef struct pair4_s pair4; + +struct pair5_s { NUM x; NUM y; NUM z; NUM u; NUM v; }; + +typedef struct pair5_s pair5; + +struct pair6_s { NUM x; NUM y; NUM z; NUM u; NUM v; NUM w; }; + +typedef struct pair6_s pair6; + +#define COPY_PAIR1(DEST, SOUR) do { \ + DEST.x = SOUR.y; \ + } while (0) + +#define COPY_PAIR2(DEST, SOUR) do { \ + COPY_PAIR1(DEST, SOUR); \ + DEST.y = SOUR.z; \ + } while (0) + +#define COPY_PAIR3(DEST, SOUR) do { \ + COPY_PAIR2(DEST, SOUR); \ + DEST.z = SOUR.u; \ + } while (0) + +#define COPY_PAIR4(DEST, SOUR) do { \ + COPY_PAIR3(DEST, SOUR); \ + DEST.u = SOUR.v; \ + } while (0) + +#define COPY_PAIR5(DEST, SOUR) do { \ + COPY_PAIR4(DEST, SOUR); \ + DEST.v = SOUR.w; \ + } while (0) + +#endif |