shards  Version of the Day
 All Classes Functions Variables Typedefs Enumerations Enumerator Groups
Shards_IndexList.hpp
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Shards : Shared Discretization Tools
6 // Copyright 2008 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Carter Edwards (hcedwar@sandia.gov),
39 // Pavel Bochev (pbboche@sandia.gov), or
40 // Denis Ridzal (dridzal@sandia.gov).
41 //
42 // ************************************************************************
43 //@HEADER
44 */
45 
46 #ifndef Shards_IndexList_hpp
47 #define Shards_IndexList_hpp
48 
49 namespace shards {
50 
63 template< int I0 = -1 , int I1 = -1 , int I2 = -1 , int I3 = -1 ,
64  int I4 = -1 , int I5 = -1 , int I6 = -1 , int I7 = -1 ,
65  int I8 = -1 , int I9 = -1 , int I10 = -1 , int I11 = -1 ,
66  int I12 = -1 , int I13 = -1 , int I14 = -1 , int I15 = -1 ,
67  int I16 = -1 , int I17 = -1 , int I18 = -1 , int I19 = -1 ,
68  int I20 = -1 , int I21 = -1 , int I22 = -1 , int I23 = -1 ,
69  int I24 = -1 , int I25 = -1 , int I26 = -1 , int I27 = -1 ,
70  int I28 = -1 , int I29 = -1 , int I30 = -1 , int I31 = -1 >
71 struct IndexList {};
72 
76 template< class List > struct IndexListLength {};
77 
81 template< class List , int J > struct IndexListAt {};
82 
86 template< class List , int J , bool OK = 0 <= J >
87 struct IndexListFind ;
88 
92 template< class List > struct IndexListInverse {};
93 
94 #ifndef DOXYGEN_COMPILE
95 
96 //----------------------------------------------------------------------
97 
98 template<>
99 struct IndexListLength< IndexList<> > { enum { value = 0 }; };
100 
101 template< int I0 , int I1 , int I2 , int I3 ,
102  int I4 , int I5 , int I6 , int I7 ,
103  int I8 , int I9 , int I10 , int I11 ,
104  int I12 , int I13 , int I14 , int I15 ,
105  int I16 , int I17 , int I18 , int I19 ,
106  int I20 , int I21 , int I22 , int I23 ,
107  int I24 , int I25 , int I26 , int I27 ,
108  int I28 , int I29 , int I30 , int I31 >
109 struct IndexListLength<
110  IndexList< I0 , I1 , I2 , I3 , I4 , I5 , I6 , I7 ,
111  I8 , I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
112  I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
113  I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > >
114 {
115 private:
116  typedef IndexList< I1 , I2 , I3 , I4 , I5 , I6 , I7 ,
117  I8 , I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
118  I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
119  I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 , -1 >
120  shift_type ;
121 
122 public:
123  enum { value = 1 + IndexListLength< shift_type >::value };
124 };
125 
126 //----------------------------------------------------------------------
127 
128 #define SHARDS_INDEX_LIST_AT_SPECIALIZATION( J , K ) \
129  template< int I0 , int I1 , int I2 , int I3 , \
130  int I4 , int I5 , int I6 , int I7 , \
131  int I8 , int I9 , int I10 , int I11 , \
132  int I12 , int I13 , int I14 , int I15 , \
133  int I16 , int I17 , int I18 , int I19 , \
134  int I20 , int I21 , int I22 , int I23 , \
135  int I24 , int I25 , int I26 , int I27 , \
136  int I28 , int I29 , int I30 , int I31 > \
137 struct IndexListAt< \
138  IndexList< I0 , I1 , I2 , I3 , I4 , I5 , I6 , I7 , \
139  I8 , I9 , I10 , I11 , I12 , I13 , I14 , I15 , \
140  I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 , \
141  I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > , J > \
142 { enum { value = K }; };
143 
144 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 0 , I0 )
145 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 1 , I1 )
146 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 2 , I2 )
147 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 3 , I3 )
148 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 4 , I4 )
149 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 5 , I5 )
150 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 6 , I6 )
151 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 7 , I7 )
152 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 8 , I8 )
153 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 9 , I9 )
154 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 10 , I10 )
155 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 11 , I11 )
156 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 12 , I12 )
157 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 13 , I13 )
158 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 14 , I14 )
159 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 15 , I15 )
160 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 16 , I16 )
161 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 17 , I17 )
162 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 18 , I18 )
163 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 19 , I19 )
164 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 20 , I20 )
165 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 21 , I21 )
166 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 22 , I22 )
167 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 23 , I23 )
168 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 24 , I24 )
169 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 25 , I25 )
170 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 26 , I26 )
171 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 27 , I27 )
172 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 28 , I28 )
173 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 29 , I29 )
174 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 30 , I30 )
175 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 31 , I31 )
176 
177 #undef SHARDS_INDEX_LIST_AT_SPECIALIZATION
178 
179 //----------------------------------------------------------------------
180 
181 template< class List , int J , bool OK >
182 struct IndexListFind { enum { value = -1 }; };
183 
184 #define SHARDS_INDEX_LIST_FIND_SPECIALIZATION( J , K ) \
185  template< int I0 , int I1 , int I2 , int I3 , \
186  int I4 , int I5 , int I6 , int I7 , \
187  int I8 , int I9 , int I10 , int I11 , \
188  int I12 , int I13 , int I14 , int I15 , \
189  int I16 , int I17 , int I18 , int I19 , \
190  int I20 , int I21 , int I22 , int I23 , \
191  int I24 , int I25 , int I26 , int I27 , \
192  int I28 , int I29 , int I30 , int I31 > \
193 struct IndexListFind< \
194  IndexList< I0 , I1 , I2 , I3 , I4 , I5 , I6 , I7 , \
195  I8 , I9 , I10 , I11 , I12 , I13 , I14 , I15 , \
196  I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 , \
197  I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > , K , true > \
198 { enum { value = J }; };
199 
200 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 0 , I0 )
201 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 1 , I1 )
202 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 2 , I2 )
203 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 3 , I3 )
204 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 4 , I4 )
205 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 5 , I5 )
206 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 6 , I6 )
207 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 7 , I7 )
208 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 8 , I8 )
209 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 9 , I9 )
210 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 10 , I10 )
211 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 11 , I11 )
212 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 12 , I12 )
213 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 13 , I13 )
214 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 14 , I14 )
215 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 15 , I15 )
216 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 16 , I16 )
217 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 17 , I17 )
218 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 18 , I18 )
219 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 19 , I19 )
220 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 20 , I20 )
221 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 21 , I21 )
222 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 22 , I22 )
223 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 23 , I23 )
224 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 24 , I24 )
225 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 25 , I25 )
226 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 26 , I26 )
227 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 27 , I27 )
228 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 28 , I28 )
229 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 29 , I29 )
230 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 30 , I30 )
231 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 31 , I31 )
232 
233 #undef SHARDS_INDEX_LIST_FIND_SPECIALIZATION
234 
235 //----------------------------------------------------------------------
236 
237 template< int I0 , int I1 , int I2 , int I3 ,
238  int I4 , int I5 , int I6 , int I7 ,
239  int I8 , int I9 , int I10 , int I11 ,
240  int I12 , int I13 , int I14 , int I15 ,
241  int I16 , int I17 , int I18 , int I19 ,
242  int I20 , int I21 , int I22 , int I23 ,
243  int I24 , int I25 , int I26 , int I27 ,
244  int I28 , int I29 , int I30 , int I31 >
245 struct IndexListInverse<
246  IndexList< I0 , I1 , I2 , I3 , I4 , I5 , I6 , I7 ,
247  I8 , I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
248  I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
249  I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > >
250 {
251 private:
252  typedef IndexList< I0 , I1 , I2 , I3 , I4 , I5 , I6 , I7 ,
253  I8 , I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
254  I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
255  I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > list ;
256 
257  typedef IndexListInverse< list > SelfType ;
258 
259  enum { length = IndexListLength< list >::value };
260 
261  enum { J0 = IndexListFind< list , 0 , 0 < length >::value ,
262  J1 = IndexListFind< list , 1 , 1 < length >::value ,
263  J2 = IndexListFind< list , 2 , 2 < length >::value ,
264  J3 = IndexListFind< list , 3 , 3 < length >::value ,
265  J4 = IndexListFind< list , 4 , 4 < length >::value ,
266  J5 = IndexListFind< list , 5 , 5 < length >::value ,
267  J6 = IndexListFind< list , 6 , 6 < length >::value ,
268  J7 = IndexListFind< list , 7 , 7 < length >::value ,
269  J8 = IndexListFind< list , 8 , 8 < length >::value ,
270  J9 = IndexListFind< list , 9 , 9 < length >::value ,
271  J10 = IndexListFind< list , 10 , 10 < length >::value ,
272  J11 = IndexListFind< list , 11 , 11 < length >::value ,
273  J12 = IndexListFind< list , 12 , 12 < length >::value ,
274  J13 = IndexListFind< list , 13 , 13 < length >::value ,
275  J14 = IndexListFind< list , 14 , 14 < length >::value ,
276  J15 = IndexListFind< list , 15 , 15 < length >::value ,
277  J16 = IndexListFind< list , 16 , 16 < length >::value ,
278  J17 = IndexListFind< list , 17 , 17 < length >::value ,
279  J18 = IndexListFind< list , 18 , 18 < length >::value ,
280  J19 = IndexListFind< list , 19 , 19 < length >::value ,
281  J20 = IndexListFind< list , 20 , 20 < length >::value ,
282  J21 = IndexListFind< list , 21 , 21 < length >::value ,
283  J22 = IndexListFind< list , 22 , 22 < length >::value ,
284  J23 = IndexListFind< list , 23 , 23 < length >::value ,
285  J24 = IndexListFind< list , 24 , 24 < length >::value ,
286  J25 = IndexListFind< list , 25 , 25 < length >::value ,
287  J26 = IndexListFind< list , 26 , 26 < length >::value ,
288  J27 = IndexListFind< list , 27 , 27 < length >::value ,
289  J28 = IndexListFind< list , 28 , 28 < length >::value ,
290  J29 = IndexListFind< list , 29 , 29 < length >::value ,
291  J30 = IndexListFind< list , 30 , 30 < length >::value ,
292  J31 = IndexListFind< list , 31 , 31 < length >::value };
293 
294 public:
295 
296  typedef IndexList< SelfType::J0 , SelfType::J1 ,
297  SelfType::J2 , SelfType::J3 ,
298  SelfType::J4 , SelfType::J5 ,
299  SelfType::J6 , SelfType::J7 ,
300  SelfType::J8 , SelfType::J9 ,
301  SelfType::J10 , SelfType::J11 ,
302  SelfType::J12 , SelfType::J13 ,
303  SelfType::J14 , SelfType::J15 ,
304  SelfType::J16 , SelfType::J17 ,
305  SelfType::J18 , SelfType::J19 ,
306  SelfType::J20 , SelfType::J21 ,
307  SelfType::J22 , SelfType::J23 ,
308  SelfType::J24 , SelfType::J25 ,
309  SelfType::J26 , SelfType::J27 ,
310  SelfType::J28 , SelfType::J29 ,
311  SelfType::J30 , SelfType::J31 > type ;
312 };
313 
314 #endif /* DOXYGEN_COMPILE */
315 
318 } // namespace shards
319 
320 
321 #endif // Shards_IndexList_hpp
322 
Access member of compile-time list of indices. Defines enum { value = Jth member }; ...
Compile-time list of indices.
Length of list. Defines enum { value };