Nektar++
ExplicitInstantiation.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // For more information, please see: http://www.nektar.info
4 //
5 // The MIT License
6 //
7 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
8 // Department of Aeronautics, Imperial College London (UK), and Scientific
9 // Computing and Imaging Institute, University of Utah (USA).
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining a
12 // copy of this software and associated documentation files (the "Software"),
13 // to deal in the Software without restriction, including without limitation
14 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 // and/or sell copies of the Software, and to permit persons to whom the
16 // Software is furnished to do so, subject to the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be included
19 // in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 // DEALINGS IN THE SOFTWARE.
28 //
29 // Description:
30 //
31 ///////////////////////////////////////////////////////////////////////////////
32 
33 #ifndef NEKTAR_LIBUTILITIES_LINEARALGEBRA_EXPLICIT_INSTANTIATION_H
34 #define NEKTAR_LIBUTILITIES_LINEARALGEBRA_EXPLICIT_INSTANTIATION_H
35 
36 #include <boost/preprocessor/arithmetic/sub.hpp>
37 #include <boost/preprocessor/array/elem.hpp>
38 #include <boost/preprocessor/array/pop_front.hpp>
39 #include <boost/preprocessor/array/push_back.hpp>
40 #include <boost/preprocessor/array/size.hpp>
41 #include <boost/preprocessor/comparison/greater.hpp>
42 #include <boost/preprocessor/comparison/less.hpp>
43 #include <boost/preprocessor/logical/bool.hpp>
44 #include <boost/preprocessor/punctuation/comma.hpp>
45 #include <boost/preprocessor/punctuation/comma_if.hpp>
46 #include <boost/preprocessor/punctuation/paren.hpp>
47 #include <boost/preprocessor/repetition/for.hpp>
48 #include <boost/preprocessor/repetition/repeat.hpp>
49 
51 
52 #define BOOST_PP_TUPLE_REM_0()
53 
54 // Macros to make creating explicit instantiations of all possible matrix types
55 // for methods easier.
56 #define NEKTAR_ALL_MATRIX_TYPES \
57  (6, (const DNekMat &, const DNekScalMat &, const DNekBlkMat &, \
58  const BlkMatDNekBlkMat &, const DNekScalBlkMat &, \
59  const BlkMatDNekScalBlkMat &))
60 #define NEKTAR_BLOCK_MATRIX_TYPES \
61  (4, (const DNekBlkMat &, const BlkMatDNekBlkMat &, const DNekScalBlkMat &, \
62  const BlkMatDNekScalBlkMat &))
63 #define NEKTAR_STANDARD_AND_SCALED_MATRICES \
64  (2, (const DNekMat &, const DNekScalMat &))
65 
66 #define NEKTAR_ALL_MATRIX_TYPES_SINGLE \
67  (6, (const SNekMat &, const SNekScalMat &, const SNekBlkMat &, \
68  const BlkMatSNekBlkMat &, const SNekScalBlkMat &, \
69  const BlkMatSNekScalBlkMat &))
70 #define NEKTAR_BLOCK_MATRIX_TYPES_SINGLE \
71  (4, (const SNekBlkMat &, const BlkMatSNekBlkMat &, const SNekScalBlkMat &, \
72  const BlkMatSNekScalBlkMat &))
73 #define NEKTAR_STANDARD_AND_SCALED_MATRICES_SINGLE \
74  (2, (const SNekMat &, const SNekScalMat &))
75 
76 #define NEKTAR_PRINT_ARRAY(z, n, data) \
77  BOOST_PP_ARRAY_ELEM(n, data) \
78  BOOST_PP_COMMA_IF( \
79  BOOST_PP_LESS(n, BOOST_PP_SUB(BOOST_PP_ARRAY_SIZE(data), 1)))
80 
81 #define NEKTAR_CREATE_EXPLICIT_INTSTANTIATION(z, n, data) \
82  template LIB_UTILITIES_EXPORT BOOST_PP_ARRAY_ELEM( \
83  0, BOOST_PP_ARRAY_ELEM(2, data)) BOOST_PP_ARRAY_ELEM(0, data) \
84  BOOST_PP_LPAREN() BOOST_PP_REPEAT( \
85  BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_ELEM(3, data)), \
86  NEKTAR_PRINT_ARRAY, BOOST_PP_ARRAY_ELEM(3, data)) \
87  BOOST_PP_COMMA_IF(BOOST_PP_GREATER( \
88  BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_ELEM(3, data)), 0)) \
89  BOOST_PP_ARRAY_ELEM(n, BOOST_PP_ARRAY_ELEM(1, data)) \
90  BOOST_PP_COMMA_IF(BOOST_PP_GREATER( \
91  BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_ELEM(4, data)), 0)) \
92  BOOST_PP_REPEAT( \
93  BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_ELEM(4, data)), \
94  NEKTAR_PRINT_ARRAY, BOOST_PP_ARRAY_ELEM(4, data)) \
95  BOOST_PP_RPAREN();
96 
97 #define NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_SINGLE_MATRIX( \
98  MethodName, MatrixTypes, ReturnType, BeforeArgs, AfterArgs) \
99  BOOST_PP_REPEAT( \
100  BOOST_PP_ARRAY_SIZE(MatrixTypes), \
101  NEKTAR_CREATE_EXPLICIT_INTSTANTIATION, \
102  (5, (MethodName, MatrixTypes, ReturnType, BeforeArgs, AfterArgs)))
103 
104 #define NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_TWO_MATRICES_INNER( \
105  z, n, data) \
106  BOOST_PP_REPEAT( \
107  BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_ELEM(2, data)), \
108  NEKTAR_CREATE_EXPLICIT_INTSTANTIATION, \
109  (5, (BOOST_PP_ARRAY_ELEM(0, data), BOOST_PP_ARRAY_ELEM(2, data), \
110  BOOST_PP_ARRAY_ELEM(3, data), \
111  BOOST_PP_ARRAY_PUSH_BACK( \
112  BOOST_PP_ARRAY_ELEM(4, data), \
113  BOOST_PP_ARRAY_ELEM(n, BOOST_PP_ARRAY_ELEM(1, data))), \
114  BOOST_PP_ARRAY_ELEM(5, data))))
115 
116 // Assumes the matrices are adjacent in parameter list.
117 #define NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_TWO_MATRICES( \
118  MethodName, FirstMatrixTypes, SecondMatrixTypes, ReturnType, BeforeArgs, \
119  AfterArgs) \
120  BOOST_PP_REPEAT( \
121  BOOST_PP_ARRAY_SIZE(FirstMatrixTypes), \
122  NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_TWO_MATRICES_INNER, \
123  (6, (MethodName, FirstMatrixTypes, SecondMatrixTypes, ReturnType, \
124  BeforeArgs, AfterArgs)))
125 
126 #endif // NEKTAR_LIBUTILITIES_LINEARALGEBRA_EXPLICIT_INSTANTIATION_H