1 | // -*- C++ -*- |
---|
2 | /*************************************************************************** |
---|
3 | * blitz/array/slice.h Helper classes for slicing arrays |
---|
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 | #ifndef BZ_ARRAYSLICE_H |
---|
32 | #define BZ_ARRAYSLICE_H |
---|
33 | |
---|
34 | // #ifndef BZ_ARRAY_H |
---|
35 | // #error <blitz/array/slice.h> must be included via <blitz/array.h> |
---|
36 | // #endif |
---|
37 | |
---|
38 | #include <blitz/range.h> |
---|
39 | |
---|
40 | BZ_NAMESPACE(blitz) |
---|
41 | |
---|
42 | // Forward declarations |
---|
43 | template<typename T, int N> |
---|
44 | class Array; |
---|
45 | |
---|
46 | class nilArraySection { }; |
---|
47 | |
---|
48 | template<typename T> |
---|
49 | class ArraySectionInfo { |
---|
50 | public: |
---|
51 | static const int isValidType = 0, rank = 0, isPick = 0; |
---|
52 | }; |
---|
53 | |
---|
54 | template<> |
---|
55 | class ArraySectionInfo<Range> { |
---|
56 | public: |
---|
57 | static const int isValidType = 1, rank = 1, isPick = 0; |
---|
58 | }; |
---|
59 | |
---|
60 | template<> |
---|
61 | class ArraySectionInfo<int> { |
---|
62 | public: |
---|
63 | static const int isValidType = 1, rank = 0, isPick = 0; |
---|
64 | }; |
---|
65 | |
---|
66 | template<> |
---|
67 | class ArraySectionInfo<nilArraySection> { |
---|
68 | public: |
---|
69 | static const int isValidType = 1, rank = 0, isPick = 0; |
---|
70 | }; |
---|
71 | |
---|
72 | template<typename T_numtype, typename T1, typename T2 = nilArraySection, |
---|
73 | class T3 = nilArraySection, typename T4 = nilArraySection, |
---|
74 | class T5 = nilArraySection, typename T6 = nilArraySection, |
---|
75 | class T7 = nilArraySection, typename T8 = nilArraySection, |
---|
76 | class T9 = nilArraySection, typename T10 = nilArraySection, |
---|
77 | class T11 = nilArraySection> |
---|
78 | class SliceInfo { |
---|
79 | public: |
---|
80 | static const int |
---|
81 | numValidTypes = ArraySectionInfo<T1>::isValidType |
---|
82 | + ArraySectionInfo<T2>::isValidType |
---|
83 | + ArraySectionInfo<T3>::isValidType |
---|
84 | + ArraySectionInfo<T4>::isValidType |
---|
85 | + ArraySectionInfo<T5>::isValidType |
---|
86 | + ArraySectionInfo<T6>::isValidType |
---|
87 | + ArraySectionInfo<T7>::isValidType |
---|
88 | + ArraySectionInfo<T8>::isValidType |
---|
89 | + ArraySectionInfo<T9>::isValidType |
---|
90 | + ArraySectionInfo<T10>::isValidType |
---|
91 | + ArraySectionInfo<T11>::isValidType, |
---|
92 | |
---|
93 | rank = ArraySectionInfo<T1>::rank |
---|
94 | + ArraySectionInfo<T2>::rank |
---|
95 | + ArraySectionInfo<T3>::rank |
---|
96 | + ArraySectionInfo<T4>::rank |
---|
97 | + ArraySectionInfo<T5>::rank |
---|
98 | + ArraySectionInfo<T6>::rank |
---|
99 | + ArraySectionInfo<T7>::rank |
---|
100 | + ArraySectionInfo<T8>::rank |
---|
101 | + ArraySectionInfo<T9>::rank |
---|
102 | + ArraySectionInfo<T10>::rank |
---|
103 | + ArraySectionInfo<T11>::rank, |
---|
104 | |
---|
105 | isPick = ArraySectionInfo<T1>::isPick |
---|
106 | + ArraySectionInfo<T2>::isPick |
---|
107 | + ArraySectionInfo<T3>::isPick |
---|
108 | + ArraySectionInfo<T4>::isPick |
---|
109 | + ArraySectionInfo<T5>::isPick |
---|
110 | + ArraySectionInfo<T6>::isPick |
---|
111 | + ArraySectionInfo<T7>::isPick |
---|
112 | + ArraySectionInfo<T8>::isPick |
---|
113 | + ArraySectionInfo<T9>::isPick |
---|
114 | + ArraySectionInfo<T10>::isPick |
---|
115 | + ArraySectionInfo<T11>::isPick; |
---|
116 | |
---|
117 | typedef Array<T_numtype,numValidTypes> T_array; |
---|
118 | typedef Array<T_numtype,rank> T_slice; |
---|
119 | }; |
---|
120 | |
---|
121 | |
---|
122 | BZ_NAMESPACE_END |
---|
123 | |
---|
124 | #endif // BZ_ARRAYSLICE_H |
---|