Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // License for the specific language governing rights and limitations under
12 // Permission is hereby granted, free of charge, to any person obtaining a
13 // copy of this software and associated documentation files (the "Software"),
14 // to deal in the Software without restriction, including without limitation
15 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 // and/or sell copies of the Software, and to permit persons to whom the
17 // Software is furnished to do so, subject to the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be included
20 // in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 // DEALINGS IN THE SOFTWARE.
29 //
30 // Description:
31 //
32 ///////////////////////////////////////////////////////////////////////////////
33 
34 
35 #ifndef NEKTAR_LIBUTILITIES_LINEARALGEBRA_EXPLICIT_INSTANTIATION_H
36 #define NEKTAR_LIBUTILITIES_LINEARALGEBRA_EXPLICIT_INSTANTIATION_H
37 
38 #include <boost/preprocessor/repetition/for.hpp>
39 #include <boost/preprocessor/array/elem.hpp>
40 #include <boost/preprocessor/array/size.hpp>
41 #include <boost/preprocessor/repetition/repeat.hpp>
42 #include <boost/preprocessor/punctuation/paren.hpp>
43 #include <boost/preprocessor/punctuation/comma_if.hpp>
44 #include <boost/preprocessor/comparison/less.hpp>
45 #include <boost/preprocessor/logical/bool.hpp>
46 #include <boost/preprocessor/arithmetic/sub.hpp>
47 #include <boost/preprocessor/punctuation/comma.hpp>
48 #include <boost/preprocessor/comparison/greater.hpp>
49 #include <boost/preprocessor/array/pop_front.hpp>
50 #include <boost/preprocessor/array/push_back.hpp>
51 #include <boost/version.hpp>
52 
54 
55 #if BOOST_VERSION > 104800
56 #define BOOST_PP_TUPLE_REM_0()
57 #endif
58 
59 // Macros to make creating explicit instantiations of all possible matrix types for methods easier.
60 #define NEKTAR_ALL_MATRIX_TYPES (6, (const DNekMat&, const DNekScalMat&, const DNekBlkMat&, const BlkMatDNekBlkMat&, const DNekScalBlkMat&, const BlkMatDNekScalBlkMat&))
61 #define NEKTAR_BLOCK_MATRIX_TYPES (4, (const DNekBlkMat&, const BlkMatDNekBlkMat&, const DNekScalBlkMat&, const BlkMatDNekScalBlkMat&))
62 #define NEKTAR_STANDARD_AND_SCALED_MATRICES (2, (const DNekMat&, const DNekScalMat&))
63 
64 #define NEKTAR_PRINT_ARRAY(z, n, data) \
65  BOOST_PP_ARRAY_ELEM(n, data) \
66  BOOST_PP_COMMA_IF(BOOST_PP_LESS(n, BOOST_PP_SUB(BOOST_PP_ARRAY_SIZE(data), 1)))
67 
68 #define NEKTAR_CREATE_EXPLICIT_INTSTANTIATION(z, n, data) \
69  template LIB_UTILITIES_EXPORT \
70  BOOST_PP_ARRAY_ELEM(0, BOOST_PP_ARRAY_ELEM(2, data)) BOOST_PP_ARRAY_ELEM(0, data) BOOST_PP_LPAREN() \
71  BOOST_PP_REPEAT(BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_ELEM(3, data)), NEKTAR_PRINT_ARRAY, BOOST_PP_ARRAY_ELEM(3, data)) \
72  BOOST_PP_COMMA_IF(BOOST_PP_GREATER(BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_ELEM(3, data)), 0)) \
73  BOOST_PP_ARRAY_ELEM(n, BOOST_PP_ARRAY_ELEM(1, data))\
74  BOOST_PP_COMMA_IF(BOOST_PP_GREATER(BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_ELEM(4, data)), 0)) \
75  BOOST_PP_REPEAT(BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_ELEM(4, data)), NEKTAR_PRINT_ARRAY, BOOST_PP_ARRAY_ELEM(4, data)) \
76  BOOST_PP_RPAREN() ;
77 
78 #define NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_SINGLE_MATRIX(MethodName, MatrixTypes, ReturnType, BeforeArgs, AfterArgs) \
79  BOOST_PP_REPEAT(BOOST_PP_ARRAY_SIZE(MatrixTypes), NEKTAR_CREATE_EXPLICIT_INTSTANTIATION, (5, (MethodName, MatrixTypes, ReturnType, BeforeArgs, AfterArgs)))
80 
81 
82 #define NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_TWO_MATRICES_INNER(z, n, data) \
83  BOOST_PP_REPEAT(BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_ELEM(2, data)), NEKTAR_CREATE_EXPLICIT_INTSTANTIATION, (5, (BOOST_PP_ARRAY_ELEM(0, data), BOOST_PP_ARRAY_ELEM(2, data), BOOST_PP_ARRAY_ELEM(3, data), BOOST_PP_ARRAY_PUSH_BACK(BOOST_PP_ARRAY_ELEM(4, data), BOOST_PP_ARRAY_ELEM(n, BOOST_PP_ARRAY_ELEM(1, data))), BOOST_PP_ARRAY_ELEM(5, data))))
84 
85 
86 // Assumes the matrices are adjacent in parameter list.
87 #define NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_TWO_MATRICES(MethodName, FirstMatrixTypes, SecondMatrixTypes, ReturnType, BeforeArgs, AfterArgs) \
88  BOOST_PP_REPEAT(BOOST_PP_ARRAY_SIZE(FirstMatrixTypes), NEKTAR_GENERATE_EXPLICIT_FUNCTION_INSTANTIATION_TWO_MATRICES_INNER, (6, (MethodName, FirstMatrixTypes, SecondMatrixTypes, ReturnType, BeforeArgs, AfterArgs)))
89 
90 
91 #endif //NEKTAR_LIBUTILITIES_LINEARALGEBRA_EXPLICIT_INSTANTIATION_H