1 | // -*- C++ -*- |
---|
2 | /*************************************************************************** |
---|
3 | * blitz/meta/matassign.h TinyMatrix assignment metaprogram |
---|
4 | * |
---|
5 | * $Id$ |
---|
6 | * |
---|
7 | * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org> |
---|
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: blitz-devel@lists.sourceforge.net |
---|
25 | * Bugs: blitz-support@lists.sourceforge.net |
---|
26 | * |
---|
27 | * For more information, please see the Blitz++ Home Page: |
---|
28 | * https://sourceforge.net/projects/blitz/ |
---|
29 | * |
---|
30 | **************************************************************************/ |
---|
31 | |
---|
32 | |
---|
33 | #ifndef BZ_META_MATASSIGN_H |
---|
34 | #define BZ_META_MATASSIGN_H |
---|
35 | |
---|
36 | BZ_NAMESPACE(blitz) |
---|
37 | |
---|
38 | template<int N_rows, int N_columns, int I, int J> |
---|
39 | class _bz_meta_matAssign2 { |
---|
40 | public: |
---|
41 | static const int go = (J < N_columns - 1) ? 1 : 0; |
---|
42 | |
---|
43 | template<typename T_matrix, typename T_expr, typename T_updater> |
---|
44 | static inline void f(T_matrix& mat, T_expr expr, T_updater u) |
---|
45 | { |
---|
46 | u.update(mat(I,J), expr(I,J)); |
---|
47 | _bz_meta_matAssign2<N_rows * go, N_columns * go, I * go, (J+1) * go> |
---|
48 | ::f(mat, expr, u); |
---|
49 | } |
---|
50 | }; |
---|
51 | |
---|
52 | template<> |
---|
53 | class _bz_meta_matAssign2<0,0,0,0> { |
---|
54 | public: |
---|
55 | template<typename T_matrix, typename T_expr, typename T_updater> |
---|
56 | static inline void f(T_matrix&, T_expr, T_updater) |
---|
57 | { } |
---|
58 | }; |
---|
59 | |
---|
60 | template<int N_rows, int N_columns, int I> |
---|
61 | class _bz_meta_matAssign { |
---|
62 | public: |
---|
63 | static const int go = (I < N_rows-1) ? 1 : 0; |
---|
64 | |
---|
65 | template<typename T_matrix, typename T_expr, typename T_updater> |
---|
66 | static inline void f(T_matrix& mat, T_expr expr, T_updater u) |
---|
67 | { |
---|
68 | _bz_meta_matAssign2<N_rows, N_columns, I, 0>::f(mat, expr, u); |
---|
69 | _bz_meta_matAssign<N_rows * go, N_columns * go, (I+1) * go> |
---|
70 | ::f(mat, expr, u); |
---|
71 | } |
---|
72 | }; |
---|
73 | |
---|
74 | template<> |
---|
75 | class _bz_meta_matAssign<0,0,0> { |
---|
76 | public: |
---|
77 | template<typename T_matrix, typename T_expr, typename T_updater> |
---|
78 | static inline void f(T_matrix&, T_expr, T_updater) |
---|
79 | { } |
---|
80 | }; |
---|
81 | |
---|
82 | |
---|
83 | BZ_NAMESPACE_END |
---|
84 | |
---|
85 | #endif // BZ_META_ASSIGN_H |
---|