source: XIOS/dev/dev_olga/src/extern/boost/include/boost/numeric/ublas/detail/duff.hpp @ 1022

Last change on this file since 1022 was 1022, checked in by mhnguyen, 7 years ago
File size: 1.3 KB
Line 
1//
2//  Copyright (c) 2000-2002
3//  Joerg Walter, Mathias Koch
4//
5//  Distributed under the Boost Software License, Version 1.0. (See
6//  accompanying file LICENSE_1_0.txt or copy at
7//  http://www.boost.org/LICENSE_1_0.txt)
8//
9//  The authors gratefully acknowledge the support of
10//  GeNeSys mbH & Co. KG in producing this work.
11//
12
13#ifndef _BOOST_UBLAS_DUFF_
14#define _BOOST_UBLAS_DUFF_
15
16#define DD_SWITCH(n, d, r, expr) \
17    { \
18        unsigned r = ((n) + (d) - 1) / (d); \
19        switch ((n) % (d))  { \
20        case 0: do { expr;
21#define DD_CASE_I(i, expr) \
22        case (i): expr;
23#define DD_WHILE(r) \
24            } while (-- (r) > 0); \
25        } \
26    }
27
28#define DD_1T(n, d, r, expr) \
29    DD_WHILE(r)
30#define DD_2T(n, d, r, expr) \
31    DD_CASE_I(1, expr) \
32    DD_1T(n, d, r, expr)
33#define DD_3T(n, d, r, expr) \
34    DD_CASE_I(2, expr) \
35    DD_2T(n, d, r, expr)
36#define DD_4T(n, d, r, expr) \
37    DD_CASE_I(3, expr) \
38    DD_3T(n, d, r, expr)
39#define DD_5T(n, d, r, expr) \
40    DD_CASE_I(4, expr) \
41    DD_4T(n, d, r, expr)
42#define DD_6T(n, d, r, expr) \
43    DD_CASE_I(5, expr) \
44    DD_5T(n, d, r, expr)
45#define DD_7T(n, d, r, expr) \
46    DD_CASE_I(6, expr) \
47    DD_6T(n, d, r, expr)
48#define DD_8T(n, d, r, expr) \
49    DD_CASE_I(7, expr) \
50    DD_7T(n, d, r, expr)
51
52#define DD(n, d, r, expr) \
53    DD_SWITCH(n, d, r, expr) \
54    DD_##d##T(n, d, r, expr)
55
56#endif
Note: See TracBrowser for help on using the repository browser.