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