| 1 | // -*- C++ -*-cxx . . $ `<file>/blitz/meta/product.h`/ |
| 2 | /*************************************************************************** |
| 3 | * blitz/meta/product.h TinyVector product metaprogram |
| 4 | * |
| 5 | * $Id$ |
| 6 | * |
| 7 | * Copyright (C) 1997-2011 Todd Veldhuizen <[email protected]> |
| 8 | * |
| 9 | * This file is a part of Blitz. |
| 10 | * |
| 11 | * Blitz is free software: you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU Lesser General Public License |
| 13 | * as published by the Free Software Foundation, either version 3 |
| 14 | * of the License, or (at your option) any later version. |
| 15 | * |
| 16 | * Blitz is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU Lesser General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU Lesser General Public |
| 22 | * License along with Blitz. If not, see <http://www.gnu.org/licenses/>. |
| 23 | * |
| 24 | * Suggestions: [email protected] |
| 25 | * Bugs: [email protected] |
| 26 | * |
| 27 | * For more information, please see the Blitz++ Home Page: |
| 28 | * https://sourceforge.net/projects/blitz/ |
| 29 | * |
| 30 | ***************************************************************************/ |
| 31 | |
| 32 | #ifndef BZ_META_PRODUCT_H |
| 33 | #define BZ_META_PRODUCT_Hcxx . . $ `blitz/meta/product.h:33:9`! |
| 34 | |
| 35 | #ifndef BZ_PROMOTE_Hcxx . . $ `blitz/promote.h:33:9`! |
| 36 | #include <blitz/promote.h> |
| 37 | #endif |
| 38 | |
| 39 | #ifndef BZ_METAPROG_H |
| 40 | #include <blitz/meta/metaprog.h>cxx . . $ `<file>/blitz/meta/metaprog.h`/ |
| 41 | #endif |
| 42 | |
| 43 | namespace blitzcxx . . $ blitz/ { |
| 44 | |
| 45 | template<int N, int I> |
| 46 | class _bz_meta_vectorProductcxx . . $ blitz/_bz_meta_vectorProduct# { |
| 47 | public: |
| 48 | static const int loopFlagcxx . . $ blitz/_bz_meta_vectorProduct#loopFlag. = (I < N-1) ? 1 : 0; |
| 49 | |
| 50 | template<typename T_expr1> |
| 51 | static inline BZ_SUMTYPEcxx . . $ `blitz/numtrait.h:42:11`!(_bz_typenamecxx . . $ `blitz/compiler.h:80:13`! T_expr1::T_numtype) |
| 52 | fcxx . . $ blitz/_bz_meta_vectorProduct#f(d8f3ecc51702e8bd).(const T_expr1& a) |
| 53 | { |
| 54 | return a[I] *cxx . . $ blitz/`operator*`(6e9d9064cd909d85). _bz_meta_vectorProductcxx . . $ blitz/_bz_meta_vectorProduct#<loopFlag * N, |
| 55 | loopFlag * (I+1)>::f(a); |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | template<> |
| 60 | class _bz_meta_vectorProductcxx . . $ blitz/_bz_meta_vectorProduct#<0,0> { |
| 61 | public: |
| 62 | template<typename T_expr1> |
| 63 | static inline _bz_meta_nullOperandcxx . . $ blitz/_bz_meta_nullOperand# fcxx . . $ blitz/_bz_meta_vectorProduct#f(38667f65db7c9f96).(const T_expr1&) |
| 64 | { return _bz_meta_nullOperandcxx . . $ blitz/_bz_meta_nullOperand#_bz_meta_nullOperand(49f6e7a06ebc5aa8).(); } |
| 65 | }; |
| 66 | |
| 67 | template<int N, int I, typename T_ret> |
| 68 | class _bz_meta_vectorProductRetcxx . . $ blitz/_bz_meta_vectorProductRet# { |
| 69 | public: |
| 70 | static const int loopFlagcxx . . $ blitz/_bz_meta_vectorProductRet#loopFlag. = (I < N-1) ? 1 : 0; |
| 71 | |
| 72 | template<typename T_expr1> |
| 73 | static inline T_ret |
| 74 | fcxx . . $ blitz/_bz_meta_vectorProductRet#f(bd728bdc4e7e20d5).(const T_expr1& a) |
| 75 | { |
| 76 | return static_cast<T_ret>(a[I]) *cxx . . $ blitz/`operator*`(6e9d9064cd909d85). _bz_meta_vectorProductRetcxx . . $ blitz/_bz_meta_vectorProductRet#<loopFlag * N, |
| 77 | loopFlag * (I+1), T_ret>::f(a); |
| 78 | } |
| 79 | }; |
| 80 | |
| 81 | template<typename T_ret> |
| 82 | class _bz_meta_vectorProductRetcxx . . $ blitz/_bz_meta_vectorProductRet#<0,0, T_ret> { |
| 83 | public: |
| 84 | template<typename T_expr1> |
| 85 | static inline _bz_meta_nullOperandcxx . . $ blitz/_bz_meta_nullOperand# fcxx . . $ blitz/_bz_meta_vectorProductRet#f(1249b7a69eba7d20).(const T_expr1&) |
| 86 | { return _bz_meta_nullOperandcxx . . $ blitz/_bz_meta_nullOperand#_bz_meta_nullOperand(49f6e7a06ebc5aa8).(); } |
| 87 | }; |
| 88 | |
| 89 | } |
| 90 | |
| 91 | #endif // BZ_META_PRODUCT_H |