shards Version of the Day
Shards_IndexList.hpp
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 //
00005 //                Shards : Shared Discretization Tools
00006 //                 Copyright 2008 Sandia Corporation
00007 //
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Carter Edwards (hcedwar@sandia.gov),
00039 //                    Pavel Bochev (pbboche@sandia.gov), or
00040 //                    Denis Ridzal (dridzal@sandia.gov).
00041 //
00042 // ************************************************************************
00043 //@HEADER
00044 */
00045 
00046 #ifndef Shards_IndexList_hpp
00047 #define Shards_IndexList_hpp
00048 
00049 namespace shards {
00050 
00063 template< int  I0 = -1 , int  I1 = -1 , int  I2 = -1 , int  I3 = -1 ,
00064           int  I4 = -1 , int  I5 = -1 , int  I6 = -1 , int  I7 = -1 ,
00065           int  I8 = -1 , int  I9 = -1 , int I10 = -1 , int I11 = -1 ,
00066           int I12 = -1 , int I13 = -1 , int I14 = -1 , int I15 = -1 ,
00067           int I16 = -1 , int I17 = -1 , int I18 = -1 , int I19 = -1 ,
00068           int I20 = -1 , int I21 = -1 , int I22 = -1 , int I23 = -1 ,
00069           int I24 = -1 , int I25 = -1 , int I26 = -1 , int I27 = -1 ,
00070           int I28 = -1 , int I29 = -1 , int I30 = -1 , int I31 = -1 >
00071 struct IndexList {};
00072 
00076 template< class List > struct IndexListLength {};
00077 
00081 template< class List , int J > struct IndexListAt {};
00082 
00086 template< class List , int J , bool OK = 0 <= J >
00087 struct IndexListFind ;
00088 
00092 template< class List > struct IndexListInverse {};
00093 
00094 #ifndef DOXYGEN_COMPILE
00095 
00096 //----------------------------------------------------------------------
00097 
00098 template<>
00099 struct IndexListLength< IndexList<> > { enum { value = 0 }; };
00100 
00101 template< int  I0 , int  I1 , int  I2 , int  I3 ,
00102           int  I4 , int  I5 , int  I6 , int  I7 ,
00103           int  I8 , int  I9 , int I10 , int I11 ,
00104           int I12 , int I13 , int I14 , int I15 ,
00105           int I16 , int I17 , int I18 , int I19 ,
00106           int I20 , int I21 , int I22 , int I23 ,
00107           int I24 , int I25 , int I26 , int I27 ,
00108           int I28 , int I29 , int I30 , int I31 >
00109 struct IndexListLength<
00110   IndexList<  I0 ,  I1 ,  I2 ,  I3 ,  I4 ,  I5 ,  I6 ,  I7 ,
00111               I8 ,  I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
00112              I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
00113              I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > >
00114 {
00115 private:
00116   typedef IndexList<        I1 ,  I2 ,  I3 ,  I4 ,  I5 ,  I6 ,  I7 ,
00117                       I8 ,  I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
00118                      I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
00119                      I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 , -1 >
00120     shift_type ;
00121 
00122 public:
00123   enum { value = 1 + IndexListLength< shift_type >::value };
00124 };
00125 
00126 //----------------------------------------------------------------------
00127 
00128 #define SHARDS_INDEX_LIST_AT_SPECIALIZATION( J , K )  \
00129   template< int  I0 , int  I1 , int  I2 , int  I3 , \
00130             int  I4 , int  I5 , int  I6 , int  I7 , \
00131             int  I8 , int  I9 , int I10 , int I11 , \
00132             int I12 , int I13 , int I14 , int I15 , \
00133             int I16 , int I17 , int I18 , int I19 , \
00134             int I20 , int I21 , int I22 , int I23 , \
00135             int I24 , int I25 , int I26 , int I27 , \
00136             int I28 , int I29 , int I30 , int I31 > \
00137 struct IndexListAt< \
00138   IndexList< I0 ,  I1 ,  I2 ,  I3 ,  I4 ,  I5 ,  I6 ,  I7 , \
00139              I8 ,  I9 , I10 , I11 , I12 , I13 , I14 , I15 , \
00140             I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 , \
00141             I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > , J > \
00142 { enum { value = K }; };
00143 
00144 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  0 ,  I0 )
00145 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  1 ,  I1 )
00146 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  2 ,  I2 )
00147 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  3 ,  I3 )
00148 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  4 ,  I4 )
00149 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  5 ,  I5 )
00150 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  6 ,  I6 )
00151 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  7 ,  I7 )
00152 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  8 ,  I8 )
00153 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  9 ,  I9 )
00154 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 10 , I10 )
00155 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 11 , I11 )
00156 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 12 , I12 )
00157 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 13 , I13 )
00158 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 14 , I14 )
00159 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 15 , I15 )
00160 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 16 , I16 )
00161 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 17 , I17 )
00162 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 18 , I18 )
00163 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 19 , I19 )
00164 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 20 , I20 )
00165 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 21 , I21 )
00166 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 22 , I22 )
00167 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 23 , I23 )
00168 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 24 , I24 )
00169 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 25 , I25 )
00170 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 26 , I26 )
00171 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 27 , I27 )
00172 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 28 , I28 )
00173 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 29 , I29 )
00174 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 30 , I30 )
00175 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 31 , I31 )
00176 
00177 #undef SHARDS_INDEX_LIST_AT_SPECIALIZATION
00178 
00179 //----------------------------------------------------------------------
00180 
00181 template< class List , int J , bool OK >
00182 struct IndexListFind { enum { value = -1 }; };
00183 
00184 #define SHARDS_INDEX_LIST_FIND_SPECIALIZATION( J , K )  \
00185   template< int  I0 , int  I1 , int  I2 , int  I3 , \
00186             int  I4 , int  I5 , int  I6 , int  I7 , \
00187             int  I8 , int  I9 , int I10 , int I11 , \
00188             int I12 , int I13 , int I14 , int I15 , \
00189             int I16 , int I17 , int I18 , int I19 , \
00190             int I20 , int I21 , int I22 , int I23 , \
00191             int I24 , int I25 , int I26 , int I27 , \
00192             int I28 , int I29 , int I30 , int I31 > \
00193 struct IndexListFind< \
00194   IndexList< I0 ,  I1 ,  I2 ,  I3 ,  I4 ,  I5 ,  I6 ,  I7 , \
00195              I8 ,  I9 , I10 , I11 , I12 , I13 , I14 , I15 , \
00196             I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 , \
00197             I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > , K , true >  \
00198 { enum { value = J }; };
00199 
00200 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  0 ,  I0 )
00201 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  1 ,  I1 )
00202 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  2 ,  I2 )
00203 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  3 ,  I3 )
00204 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  4 ,  I4 )
00205 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  5 ,  I5 )
00206 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  6 ,  I6 )
00207 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  7 ,  I7 )
00208 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  8 ,  I8 )
00209 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  9 ,  I9 )
00210 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 10 , I10 )
00211 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 11 , I11 )
00212 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 12 , I12 )
00213 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 13 , I13 )
00214 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 14 , I14 )
00215 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 15 , I15 )
00216 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 16 , I16 )
00217 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 17 , I17 )
00218 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 18 , I18 )
00219 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 19 , I19 )
00220 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 20 , I20 )
00221 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 21 , I21 )
00222 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 22 , I22 )
00223 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 23 , I23 )
00224 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 24 , I24 )
00225 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 25 , I25 )
00226 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 26 , I26 )
00227 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 27 , I27 )
00228 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 28 , I28 )
00229 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 29 , I29 )
00230 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 30 , I30 )
00231 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 31 , I31 )
00232 
00233 #undef SHARDS_INDEX_LIST_FIND_SPECIALIZATION
00234 
00235 //----------------------------------------------------------------------
00236 
00237 template< int  I0 , int  I1 , int  I2 , int  I3 ,
00238           int  I4 , int  I5 , int  I6 , int  I7 ,
00239           int  I8 , int  I9 , int I10 , int I11 ,
00240           int I12 , int I13 , int I14 , int I15 ,
00241           int I16 , int I17 , int I18 , int I19 ,
00242           int I20 , int I21 , int I22 , int I23 ,
00243           int I24 , int I25 , int I26 , int I27 ,
00244           int I28 , int I29 , int I30 , int I31 >
00245 struct IndexListInverse<
00246   IndexList<  I0 ,  I1 ,  I2 ,  I3 ,  I4 ,  I5 ,  I6 ,  I7 ,
00247               I8 ,  I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
00248              I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
00249              I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > >
00250 {
00251 private:
00252   typedef IndexList<  I0 ,  I1 ,  I2 ,  I3 ,  I4 ,  I5 ,  I6 ,  I7 ,
00253                       I8 ,  I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
00254                      I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
00255                      I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > list ;
00256 
00257   typedef IndexListInverse< list > SelfType ;
00258 
00259   enum { length = IndexListLength< list >::value };
00260 
00261   enum { J0  = IndexListFind< list ,  0 ,  0 < length >::value ,
00262          J1  = IndexListFind< list ,  1 ,  1 < length >::value ,
00263          J2  = IndexListFind< list ,  2 ,  2 < length >::value ,
00264          J3  = IndexListFind< list ,  3 ,  3 < length >::value ,
00265          J4  = IndexListFind< list ,  4 ,  4 < length >::value ,
00266          J5  = IndexListFind< list ,  5 ,  5 < length >::value ,
00267          J6  = IndexListFind< list ,  6 ,  6 < length >::value ,
00268          J7  = IndexListFind< list ,  7 ,  7 < length >::value ,
00269          J8  = IndexListFind< list ,  8 ,  8 < length >::value ,
00270          J9  = IndexListFind< list ,  9 ,  9 < length >::value ,
00271          J10 = IndexListFind< list , 10 , 10 < length >::value ,
00272          J11 = IndexListFind< list , 11 , 11 < length >::value ,
00273          J12 = IndexListFind< list , 12 , 12 < length >::value ,
00274          J13 = IndexListFind< list , 13 , 13 < length >::value ,
00275          J14 = IndexListFind< list , 14 , 14 < length >::value ,
00276          J15 = IndexListFind< list , 15 , 15 < length >::value ,
00277          J16 = IndexListFind< list , 16 , 16 < length >::value ,
00278          J17 = IndexListFind< list , 17 , 17 < length >::value ,
00279          J18 = IndexListFind< list , 18 , 18 < length >::value ,
00280          J19 = IndexListFind< list , 19 , 19 < length >::value ,
00281          J20 = IndexListFind< list , 20 , 20 < length >::value ,
00282          J21 = IndexListFind< list , 21 , 21 < length >::value ,
00283          J22 = IndexListFind< list , 22 , 22 < length >::value ,
00284          J23 = IndexListFind< list , 23 , 23 < length >::value ,
00285          J24 = IndexListFind< list , 24 , 24 < length >::value ,
00286          J25 = IndexListFind< list , 25 , 25 < length >::value ,
00287          J26 = IndexListFind< list , 26 , 26 < length >::value ,
00288          J27 = IndexListFind< list , 27 , 27 < length >::value ,
00289          J28 = IndexListFind< list , 28 , 28 < length >::value ,
00290          J29 = IndexListFind< list , 29 , 29 < length >::value ,
00291          J30 = IndexListFind< list , 30 , 30 < length >::value ,
00292          J31 = IndexListFind< list , 31 , 31 < length >::value };
00293 
00294 public:
00295 
00296   typedef IndexList< SelfType::J0 ,  SelfType::J1 ,
00297                      SelfType::J2 ,  SelfType::J3 , 
00298                      SelfType::J4 ,  SelfType::J5 , 
00299                      SelfType::J6 ,  SelfType::J7 , 
00300                      SelfType::J8 ,  SelfType::J9 , 
00301                      SelfType::J10 , SelfType::J11 ,
00302                      SelfType::J12 , SelfType::J13 ,
00303                      SelfType::J14 , SelfType::J15 ,
00304                      SelfType::J16 , SelfType::J17 ,
00305                      SelfType::J18 , SelfType::J19 ,
00306                      SelfType::J20 , SelfType::J21 ,
00307                      SelfType::J22 , SelfType::J23 ,
00308                      SelfType::J24 , SelfType::J25 ,
00309                      SelfType::J26 , SelfType::J27 ,
00310                      SelfType::J28 , SelfType::J29 ,
00311                      SelfType::J30 , SelfType::J31 > type ;
00312 };
00313 
00314 #endif /* DOXYGEN_COMPILE */
00315 
00318 } // namespace shards
00319 
00320 
00321 #endif // Shards_IndexList_hpp
00322 
 All Classes Functions Variables Typedefs Enumerator