[857] | 1 | //
|
---|
| 2 | // Copyright (c) 2000-2002
|
---|
| 3 | // Joerg Walter, Mathias Koch
|
---|
| 4 | //
|
---|
| 5 | // Permission to use, copy, modify, distribute and sell this software
|
---|
| 6 | // and its documentation for any purpose is hereby granted without fee,
|
---|
| 7 | // provided that the above copyright notice appear in all copies and
|
---|
| 8 | // that both that copyright notice and this permission notice appear
|
---|
| 9 | // in supporting documentation. The authors make no representations
|
---|
| 10 | // about the suitability of this software for any purpose.
|
---|
| 11 | // It is provided "as is" without express or implied warranty.
|
---|
| 12 | //
|
---|
| 13 | // The authors gratefully acknowledge the support of
|
---|
| 14 | // GeNeSys mbH & Co. KG in producing this work.
|
---|
| 15 | //
|
---|
| 16 |
|
---|
| 17 | #ifndef _BOOST_UBLAS_DUFF_
|
---|
| 18 | #define _BOOST_UBLAS_DUFF_
|
---|
| 19 |
|
---|
| 20 | #define DD_SWITCH(n, d, r, expr) \
|
---|
| 21 | { \
|
---|
| 22 | unsigned r = ((n) + (d) - 1) / (d); \
|
---|
| 23 | switch ((n) % (d)) { \
|
---|
| 24 | case 0: do { expr;
|
---|
| 25 | #define DD_CASE_I(i, expr) \
|
---|
| 26 | case (i): expr;
|
---|
| 27 | #define DD_WHILE(r) \
|
---|
| 28 | } while (-- (r) > 0); \
|
---|
| 29 | } \
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | #define DD_1T(n, d, r, expr) \
|
---|
| 33 | DD_WHILE(r)
|
---|
| 34 | #define DD_2T(n, d, r, expr) \
|
---|
| 35 | DD_CASE_I(1, expr) \
|
---|
| 36 | DD_1T(n, d, r, expr)
|
---|
| 37 | #define DD_3T(n, d, r, expr) \
|
---|
| 38 | DD_CASE_I(2, expr) \
|
---|
| 39 | DD_2T(n, d, r, expr)
|
---|
| 40 | #define DD_4T(n, d, r, expr) \
|
---|
| 41 | DD_CASE_I(3, expr) \
|
---|
| 42 | DD_3T(n, d, r, expr)
|
---|
| 43 | #define DD_5T(n, d, r, expr) \
|
---|
| 44 | DD_CASE_I(4, expr) \
|
---|
| 45 | DD_4T(n, d, r, expr)
|
---|
| 46 | #define DD_6T(n, d, r, expr) \
|
---|
| 47 | DD_CASE_I(5, expr) \
|
---|
| 48 | DD_5T(n, d, r, expr)
|
---|
| 49 | #define DD_7T(n, d, r, expr) \
|
---|
| 50 | DD_CASE_I(6, expr) \
|
---|
| 51 | DD_6T(n, d, r, expr)
|
---|
| 52 | #define DD_8T(n, d, r, expr) \
|
---|
| 53 | DD_CASE_I(7, expr) \
|
---|
| 54 | DD_7T(n, d, r, expr)
|
---|
| 55 |
|
---|
| 56 | #define DD(n, d, r, expr) \
|
---|
| 57 | DD_SWITCH(n, d, r, expr) \
|
---|
| 58 | DD_##d##T(n, d, r, expr)
|
---|
| 59 |
|
---|
| 60 | #endif
|
---|