Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

src/AppTypes/TSVMetaBinary.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  *
00007  * Visit http://people.web.psi.ch/adelmann/ for more details
00008  *
00009  ***************************************************************************/
00010 
00011 #ifndef TSV_META_BINARY_H
00012 #define TSV_META_BINARY_H
00013 
00015 //
00016 // Definition of structs TSV_MetaBinary and TSV_MetaBinaryScalar
00017 //
00019 
00020 template<class T1, class T2, class OP> struct TSV_MetaBinary {};
00021 template<class T1, class T2, class OP> struct TSV_MetaBinaryScalar {};
00022 
00024 //
00025 // Specializations for Vektors of arbitrary size.
00026 //
00028 
00029 template<class T1, class T2, class OP, unsigned D>
00030 struct TSV_MetaBinary< Vektor<T1,D> , Vektor<T2,D> , OP >
00031 {
00032   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00033   inline static Vektor<T0,D>
00034   apply(const Vektor<T1,D>& lhs, const Vektor<T2,D>& rhs) {
00035     Vektor<T0,D> ret;
00036     for (unsigned d=0; d<D; ++d)
00037       ret[d] = PETE_apply(OP(),lhs[d] , rhs[d]);
00038     return ret;
00039   }
00040 };
00041 
00042 template<class T1, class T2, class OP, unsigned D>
00043 struct TSV_MetaBinaryScalar< Vektor<T1,D> , T2 , OP >
00044 {
00045   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00046   inline static Vektor<T0,D>
00047   apply(const Vektor<T1,D>& lhs, T2 rhs) {
00048     Vektor<T0,D> ret;
00049     for (unsigned d=0; d<D; ++d)
00050       ret[d] = PETE_apply( OP(), lhs[d] , rhs );
00051     return ret;
00052   }
00053 };
00054 
00055 template<class T1, class T2, class OP, unsigned D>
00056 struct TSV_MetaBinaryScalar< T1, Vektor<T2,D> , OP >
00057 {
00058   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00059   inline static Vektor<T0,D>
00060   apply(T1 lhs, const Vektor<T2,D>& rhs) {
00061     Vektor<T0,D> ret;
00062     for (unsigned d=0; d<D; ++d)
00063       ret[d] = PETE_apply( OP(), lhs , rhs[d]);
00064     return ret;
00065   }
00066 };
00067 
00069 //
00070 // Specializations of TSV_MetaBinary for Vektors with D=1.
00071 //
00073 
00074 template<class T1, class T2, class OP>
00075 struct TSV_MetaBinary< Vektor<T1,1> , Vektor<T2,1> , OP >
00076 {
00077   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00078   inline static Vektor<T0,1>
00079   apply(const Vektor<T1,1>& lhs, const Vektor<T2,1>& rhs) {
00080     return Vektor<T0,1>( PETE_apply( OP(), lhs[0], rhs[0] ) );
00081   }
00082 };
00083 
00084 template<class T1, class T2, class OP>
00085 struct TSV_MetaBinaryScalar< Vektor<T1,1> , T2 , OP >
00086 {
00087   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00088   inline static Vektor<T0,1>
00089   apply(const Vektor<T1,1>& lhs, T2 rhs) {
00090     return Vektor<T0,1>( PETE_apply( OP(), lhs[0], rhs ) );
00091   }
00092 };
00093 
00094 template<class T1, class T2, class OP>
00095 struct TSV_MetaBinaryScalar< T1, Vektor<T2,1> , OP >
00096 {
00097   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00098   inline static Vektor<T0,1>
00099   apply(T1 lhs, const Vektor<T2,1>& rhs) {
00100     return Vektor<T0,1>( PETE_apply( OP(), lhs, rhs[0] ) );
00101   }
00102 };
00103 
00105 //
00106 // Specializations of TSV_MetaBinary for Vektors with D=2.
00107 //
00109 
00110 template<class T1, class T2, class OP>
00111 struct TSV_MetaBinary< Vektor<T1,2> , Vektor<T2,2> , OP >
00112 {
00113   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00114   inline static Vektor<T0,2>
00115   apply(const Vektor<T1,2>& lhs, const Vektor<T2,2>& rhs) {
00116     return Vektor<T0,2>( PETE_apply( OP(), lhs[0], rhs[0] ) ,
00117                          PETE_apply( OP(), lhs[1], rhs[1] ) );
00118   }
00119 };
00120 
00121 template<class T1, class T2, class OP>
00122 struct TSV_MetaBinaryScalar< Vektor<T1,2> , T2 , OP >
00123 {
00124   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00125   inline static Vektor<T0,2>
00126   apply(const Vektor<T1,2>& lhs, T2 rhs) {
00127     return Vektor<T0,2>( PETE_apply( OP(), lhs[0], rhs ) ,
00128                          PETE_apply( OP(), lhs[1], rhs ) );
00129   }
00130 };
00131 
00132 template<class T1, class T2, class OP>
00133 struct TSV_MetaBinaryScalar< T1, Vektor<T2,2> , OP >
00134 {
00135   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00136   inline static Vektor<T0,2>
00137   apply(T1 lhs, const Vektor<T2,2>& rhs) {
00138     return Vektor<T0,2>( PETE_apply( OP(), lhs, rhs[0] ) ,
00139                          PETE_apply( OP(), lhs, rhs[1] ) );
00140   }
00141 };
00142 
00144 //
00145 // Specializations of TSV_MetaBinary for Vektors with D=3.
00146 //
00148 
00149 template<class T1, class T2, class OP>
00150 struct TSV_MetaBinary< Vektor<T1,3> , Vektor<T2,3> , OP >
00151 {
00152   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00153   inline static Vektor<T0,3>
00154   apply(const Vektor<T1,3>& lhs, const Vektor<T2,3>& rhs) {
00155     return Vektor<T0,3>( PETE_apply( OP(), lhs[0], rhs[0] ) ,
00156                          PETE_apply( OP(), lhs[1], rhs[1] ) ,
00157                          PETE_apply( OP(), lhs[2], rhs[2] ) );
00158   }
00159 };
00160 
00161 template<class T1, class T2, class OP>
00162 struct TSV_MetaBinaryScalar< Vektor<T1,3> , T2 , OP >
00163 {
00164   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00165   inline static Vektor<T0,3>
00166   apply(const Vektor<T1,3>& lhs, T2 rhs) {
00167     return Vektor<T0,3>( PETE_apply( OP(), lhs[0], rhs ) ,
00168                          PETE_apply( OP(), lhs[1], rhs ) ,
00169                          PETE_apply( OP(), lhs[2], rhs ) );
00170   }
00171 };
00172 
00173 template<class T1, class T2, class OP>
00174 struct TSV_MetaBinaryScalar< T1, Vektor<T2,3> , OP >
00175 {
00176   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00177   inline static Vektor<T0,3>
00178   apply(T1 lhs, const Vektor<T2,3>& rhs) {
00179     return Vektor<T0,3>( PETE_apply( OP(), lhs, rhs[0] ) ,
00180                          PETE_apply( OP(), lhs, rhs[1] ) ,
00181                          PETE_apply( OP(), lhs, rhs[2] ) );
00182   }
00183 };
00184 
00186 //
00187 // Specializations for Tenzors of arbitrary size.
00188 //
00190 
00191 template<class T1, class T2, class OP, unsigned D>
00192 struct TSV_MetaBinary< Tenzor<T1,D> , Tenzor<T2,D> , OP >
00193 {
00194   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00195   inline static Tenzor<T0,D>
00196   apply(const Tenzor<T1,D>& lhs, const Tenzor<T2,D>& rhs) {
00197     Tenzor<T0,D> ret;
00198     for (unsigned d=0; d<D*D; ++d)
00199       ret[d] = PETE_apply(OP(),lhs[d] , rhs[d]);
00200     return ret;
00201   }
00202 };
00203 
00204 template<class T1, class T2, class OP, unsigned D>
00205 struct TSV_MetaBinaryScalar< Tenzor<T1,D> , T2 , OP >
00206 {
00207   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00208   inline static Tenzor<T0,D>
00209   apply(const Tenzor<T1,D>& lhs, T2 rhs) {
00210     Tenzor<T0,D> ret;
00211     for (unsigned d=0; d<D*D; ++d)
00212       ret[d] = PETE_apply( OP(), lhs[d] , rhs );
00213     return ret;
00214   }
00215 };
00216 
00217 template<class T1, class T2, class OP, unsigned D>
00218 struct TSV_MetaBinaryScalar< T1, Tenzor<T2,D> , OP >
00219 {
00220   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00221   inline static Tenzor<T0,D>
00222   apply(T1 lhs, const Tenzor<T2,D>& rhs) {
00223     Tenzor<T0,D> ret;
00224     for (unsigned d=0; d<D*D; ++d)
00225       ret[d] = PETE_apply( OP(), lhs , rhs[d]);
00226     return ret;
00227   }
00228 };
00229 
00231 //
00232 // Specializations of TSV_MetaBinary for Tenzors with D=1.
00233 //
00235 
00236 template<class T1, class T2, class OP>
00237 struct TSV_MetaBinary< Tenzor<T1,1> , Tenzor<T2,1> , OP >
00238 {
00239   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00240   inline static Tenzor<T0,1>
00241   apply(const Tenzor<T1,1>& lhs, const Tenzor<T2,1>& rhs) {
00242     return Tenzor<T0,1>( PETE_apply( OP(), lhs[0], rhs[0] ) );
00243   }
00244 };
00245 
00246 template<class T1, class T2, class OP>
00247 struct TSV_MetaBinaryScalar< Tenzor<T1,1> , T2 , OP >
00248 {
00249   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00250   inline static Tenzor<T0,1>
00251   apply(const Tenzor<T1,1>& lhs, T2 rhs) {
00252     return Tenzor<T0,1>( PETE_apply( OP(), lhs[0], rhs ) );
00253   }
00254 };
00255 
00256 template<class T1, class T2, class OP>
00257 struct TSV_MetaBinaryScalar< T1, Tenzor<T2,1> , OP >
00258 {
00259   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00260   inline static Tenzor<T0,1>
00261   apply(T1 lhs, const Tenzor<T2,1>& rhs) {
00262     return Tenzor<T0,1>( PETE_apply( OP(), lhs, rhs[0] ) );
00263   }
00264 };
00265 
00267 //
00268 // Specializations of TSV_MetaBinary for Tenzors with D=2.
00269 //
00271 
00272 template<class T1, class T2, class OP>
00273 struct TSV_MetaBinary< Tenzor<T1,2> , Tenzor<T2,2> , OP >
00274 {
00275   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00276   inline static Tenzor<T0,2>
00277   apply(const Tenzor<T1,2>& lhs, const Tenzor<T2,2>& rhs) {
00278     return Tenzor<T0,2>( PETE_apply( OP(), lhs[0], rhs[0] ) ,
00279                          PETE_apply( OP(), lhs[1], rhs[1] ) ,
00280                          PETE_apply( OP(), lhs[2], rhs[2] ) ,
00281                          PETE_apply( OP(), lhs[3], rhs[3] ) );
00282   }
00283 };
00284 
00285 template<class T1, class T2, class OP>
00286 struct TSV_MetaBinaryScalar< Tenzor<T1,2> , T2 , OP >
00287 {
00288   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00289   inline static Tenzor<T0,2>
00290   apply(const Tenzor<T1,2>& lhs, T2 rhs) {
00291     return Tenzor<T0,2>( PETE_apply( OP(), lhs[0], rhs ) ,
00292                          PETE_apply( OP(), lhs[1], rhs ) ,
00293                          PETE_apply( OP(), lhs[2], rhs ) ,
00294                          PETE_apply( OP(), lhs[3], rhs ) );
00295   }
00296 };
00297 
00298 template<class T1, class T2, class OP>
00299 struct TSV_MetaBinaryScalar< T1, Tenzor<T2,2> , OP >
00300 {
00301   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00302   inline static Tenzor<T0,2>
00303   apply(T1 lhs, const Tenzor<T2,2>& rhs) {
00304     return Tenzor<T0,2>( PETE_apply( OP(), lhs, rhs[0] ) ,
00305                          PETE_apply( OP(), lhs, rhs[1] ) ,
00306                          PETE_apply( OP(), lhs, rhs[2] ) ,
00307                          PETE_apply( OP(), lhs, rhs[3] ) );
00308   }
00309 };
00310 
00312 //
00313 // Specializations of TSV_MetaBinary for Tenzors with D=3.
00314 //
00316 
00317 template<class T1, class T2, class OP>
00318 struct TSV_MetaBinary< Tenzor<T1,3> , Tenzor<T2,3> , OP >
00319 {
00320   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00321   inline static Tenzor<T0,3>
00322   apply(const Tenzor<T1,3>& lhs, const Tenzor<T2,3>& rhs) {
00323     return Tenzor<T0,3>( PETE_apply( OP(), lhs[0], rhs[0] ) ,
00324                          PETE_apply( OP(), lhs[1], rhs[1] ) ,
00325                          PETE_apply( OP(), lhs[2], rhs[2] ) ,
00326                          PETE_apply( OP(), lhs[3], rhs[3] ) ,
00327                          PETE_apply( OP(), lhs[4], rhs[4] ) ,
00328                          PETE_apply( OP(), lhs[5], rhs[5] ) ,
00329                          PETE_apply( OP(), lhs[6], rhs[6] ) ,
00330                          PETE_apply( OP(), lhs[7], rhs[7] ) ,
00331                          PETE_apply( OP(), lhs[8], rhs[8] ) );
00332   }
00333 };
00334 
00335 template<class T1, class T2, class OP>
00336 struct TSV_MetaBinaryScalar< Tenzor<T1,3> , T2 , OP >
00337 {
00338   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00339   inline static Tenzor<T0,3>
00340   apply(const Tenzor<T1,3>& lhs, T2 rhs) {
00341     return Tenzor<T0,3>( PETE_apply( OP(), lhs[0], rhs ) ,
00342                          PETE_apply( OP(), lhs[1], rhs ) ,
00343                          PETE_apply( OP(), lhs[2], rhs ) ,
00344                          PETE_apply( OP(), lhs[3], rhs ) ,
00345                          PETE_apply( OP(), lhs[4], rhs ) ,
00346                          PETE_apply( OP(), lhs[5], rhs ) ,
00347                          PETE_apply( OP(), lhs[6], rhs ) ,
00348                          PETE_apply( OP(), lhs[7], rhs ) ,
00349                          PETE_apply( OP(), lhs[8], rhs ) );
00350   }
00351 };
00352 
00353 template<class T1, class T2, class OP>
00354 struct TSV_MetaBinaryScalar< T1, Tenzor<T2,3> , OP >
00355 {
00356   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00357   inline static Tenzor<T0,3>
00358   apply(T1 lhs, const Tenzor<T2,3>& rhs) {
00359     return Tenzor<T0,3>( PETE_apply( OP(), lhs, rhs[0] ) ,
00360                          PETE_apply( OP(), lhs, rhs[1] ) ,
00361                          PETE_apply( OP(), lhs, rhs[2] ) ,
00362                          PETE_apply( OP(), lhs, rhs[3] ) ,
00363                          PETE_apply( OP(), lhs, rhs[4] ) ,
00364                          PETE_apply( OP(), lhs, rhs[5] ) ,
00365                          PETE_apply( OP(), lhs, rhs[6] ) ,
00366                          PETE_apply( OP(), lhs, rhs[7] ) ,
00367                          PETE_apply( OP(), lhs, rhs[8] ) );
00368   }
00369 };
00370 
00372 //
00373 // Specializations for SymTenzors of arbitrary size.
00374 //
00376 
00377 template<class T1, class T2, class OP, unsigned D>
00378 struct TSV_MetaBinary< SymTenzor<T1,D> , SymTenzor<T2,D> , OP >
00379 {
00380   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00381   inline static SymTenzor<T0,D>
00382   apply(const SymTenzor<T1,D>& lhs, const SymTenzor<T2,D>& rhs) {
00383     SymTenzor<T0,D> ret;
00384     for (unsigned d=0; d<D*(D+1)/2; ++d)
00385       ret[d] = PETE_apply(OP(),lhs[d] , rhs[d]);
00386     return ret;
00387   }
00388 };
00389 
00390 template<class T1, class T2, class OP, unsigned D>
00391 struct TSV_MetaBinaryScalar< SymTenzor<T1,D> , T2 , OP >
00392 {
00393   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00394   inline static SymTenzor<T0,D>
00395   apply(const SymTenzor<T1,D>& lhs, T2 rhs) {
00396     SymTenzor<T0,D> ret;
00397     for (unsigned d=0; d<D*(D+1)/2; ++d)
00398       ret[d] = PETE_apply( OP(), lhs[d] , rhs );
00399     return ret;
00400   }
00401 };
00402 
00403 template<class T1, class T2, class OP, unsigned D>
00404 struct TSV_MetaBinaryScalar< T1, SymTenzor<T2,D> , OP >
00405 {
00406   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00407   inline static SymTenzor<T0,D>
00408   apply(T1 lhs, const SymTenzor<T2,D>& rhs) {
00409     SymTenzor<T0,D> ret;
00410     for (unsigned d=0; d<D*(D+1)/2; ++d)
00411       ret[d] = PETE_apply( OP(), lhs , rhs[d]);
00412     return ret;
00413   }
00414 };
00415 
00417 //
00418 // Specializations of TSV_MetaBinary for SymTenzors with D=1.
00419 //
00421 
00422 template<class T1, class T2, class OP>
00423 struct TSV_MetaBinary< SymTenzor<T1,1> , SymTenzor<T2,1> , OP >
00424 {
00425   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00426   inline static SymTenzor<T0,1>
00427   apply(const SymTenzor<T1,1>& lhs, const SymTenzor<T2,1>& rhs) {
00428     return SymTenzor<T0,1>( PETE_apply( OP(), lhs[0], rhs[0] ) );
00429   }
00430 };
00431 
00432 template<class T1, class T2, class OP>
00433 struct TSV_MetaBinaryScalar< SymTenzor<T1,1> , T2 , OP >
00434 {
00435   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00436   inline static SymTenzor<T0,1>
00437   apply(const SymTenzor<T1,1>& lhs, T2 rhs) {
00438     return SymTenzor<T0,1>( PETE_apply( OP(), lhs[0], rhs ) );
00439   }
00440 };
00441 
00442 template<class T1, class T2, class OP>
00443 struct TSV_MetaBinaryScalar< T1, SymTenzor<T2,1> , OP >
00444 {
00445   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00446   inline static SymTenzor<T0,1>
00447   apply(T1 lhs, const SymTenzor<T2,1>& rhs) {
00448     return SymTenzor<T0,1>( PETE_apply( OP(), lhs, rhs[0] ) );
00449   }
00450 };
00451 
00453 //
00454 // Specializations of TSV_MetaBinary for SymTenzors with D=2.
00455 //
00457 
00458 template<class T1, class T2, class OP>
00459 struct TSV_MetaBinary< SymTenzor<T1,2> , SymTenzor<T2,2> , OP >
00460 {
00461   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00462   inline static SymTenzor<T0,2>
00463   apply(const SymTenzor<T1,2>& lhs, const SymTenzor<T2,2>& rhs) {
00464     return SymTenzor<T0,2>( PETE_apply( OP(), lhs[0], rhs[0] ) ,
00465                             PETE_apply( OP(), lhs[1], rhs[1] ) ,
00466                             PETE_apply( OP(), lhs[2], rhs[2] ) );
00467   }
00468 };
00469 
00470 template<class T1, class T2, class OP>
00471 struct TSV_MetaBinaryScalar< SymTenzor<T1,2> , T2 , OP >
00472 {
00473   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00474   inline static SymTenzor<T0,2>
00475   apply(const SymTenzor<T1,2>& lhs, T2 rhs) {
00476     return SymTenzor<T0,2>( PETE_apply( OP(), lhs[0], rhs ) ,
00477                             PETE_apply( OP(), lhs[1], rhs ) ,
00478                             PETE_apply( OP(), lhs[2], rhs ) );
00479   }
00480 };
00481 
00482 template<class T1, class T2, class OP>
00483 struct TSV_MetaBinaryScalar< T1, SymTenzor<T2,2> , OP >
00484 {
00485   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00486   inline static SymTenzor<T0,2>
00487   apply(T1 lhs, const SymTenzor<T2,2>& rhs) {
00488     return SymTenzor<T0,2>( PETE_apply( OP(), lhs, rhs[0] ) ,
00489                             PETE_apply( OP(), lhs, rhs[1] ) ,
00490                             PETE_apply( OP(), lhs, rhs[2] ) );
00491   }
00492 };
00493 
00495 //
00496 // Specializations of TSV_MetaBinary for SymTenzors with D=3.
00497 //
00499 
00500 template<class T1, class T2, class OP>
00501 struct TSV_MetaBinary< SymTenzor<T1,3> , SymTenzor<T2,3> , OP >
00502 {
00503   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00504   inline static SymTenzor<T0,3>
00505   apply(const SymTenzor<T1,3>& lhs, const SymTenzor<T2,3>& rhs) {
00506     return SymTenzor<T0,3>( PETE_apply( OP(), lhs[0], rhs[0] ) ,
00507                             PETE_apply( OP(), lhs[1], rhs[1] ) ,
00508                             PETE_apply( OP(), lhs[2], rhs[2] ) ,
00509                             PETE_apply( OP(), lhs[3], rhs[3] ) ,
00510                             PETE_apply( OP(), lhs[4], rhs[4] ) ,
00511                             PETE_apply( OP(), lhs[5], rhs[5] ) );
00512   }
00513 };
00514 
00515 template<class T1, class T2, class OP>
00516 struct TSV_MetaBinaryScalar< SymTenzor<T1,3> , T2 , OP >
00517 {
00518   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00519   inline static SymTenzor<T0,3>
00520   apply(const SymTenzor<T1,3>& lhs, T2 rhs) {
00521     return SymTenzor<T0,3>( PETE_apply( OP(), lhs[0], rhs ) ,
00522                             PETE_apply( OP(), lhs[1], rhs ) ,
00523                             PETE_apply( OP(), lhs[2], rhs ) ,
00524                             PETE_apply( OP(), lhs[3], rhs ) ,
00525                             PETE_apply( OP(), lhs[4], rhs ) ,
00526                             PETE_apply( OP(), lhs[5], rhs ) );
00527   }
00528 };
00529 
00530 template<class T1, class T2, class OP>
00531 struct TSV_MetaBinaryScalar< T1, SymTenzor<T2,3> , OP >
00532 {
00533   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00534   inline static SymTenzor<T0,3>
00535   apply(T1 lhs, const SymTenzor<T2,3>& rhs) {
00536     return SymTenzor<T0,3>( PETE_apply( OP(), lhs, rhs[0] ) ,
00537                             PETE_apply( OP(), lhs, rhs[1] ) ,
00538                             PETE_apply( OP(), lhs, rhs[2] ) ,
00539                             PETE_apply( OP(), lhs, rhs[3] ) ,
00540                             PETE_apply( OP(), lhs, rhs[4] ) ,
00541                             PETE_apply( OP(), lhs, rhs[5] ) );
00542   }
00543 };
00544 
00546 //
00547 // Specialization for SymTenzor OP Tenzor of arbitrary size.
00548 //
00550 
00551 template<class T1, class T2, class OP, unsigned D>
00552 struct TSV_MetaBinary< SymTenzor<T1,D>, Tenzor<T2,D>, OP >
00553 {
00554   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00555   inline static Tenzor<T0,D>
00556   apply(const SymTenzor<T1,D> &lhs, const Tenzor<T2,D> &rhs) {
00557     Tenzor<T0,D> ret;
00558     for (unsigned i = 0; i < D; i++)
00559       for (unsigned j = 0; j < D; j++)
00560         ret(i, j) = PETE_apply(OP(), lhs(i, j), rhs(i, j));
00561     return ret;
00562   }
00563 };
00564 
00566 //
00567 // Specialization for Tenzor OP SymTenzor of arbitrary size.
00568 //
00570 
00571 template<class T1, class T2, class OP, unsigned D>
00572 struct TSV_MetaBinary< Tenzor<T1,D>, SymTenzor<T2,D>, OP >
00573 {
00574   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00575   inline static Tenzor<T0,D>
00576   apply(const Tenzor<T1,D> &lhs, const SymTenzor<T2,D> &rhs) {
00577     Tenzor<T0,D> ret;
00578     for (unsigned i = 0; i < D; i++)
00579       for (unsigned j = 0; j < D; j++)
00580         ret(i, j) = PETE_apply(OP(), lhs(i, j), rhs(i, j));
00581     return ret;
00582   }
00583 };
00584 
00586 //
00587 // Specializations for AntiSymTenzors of arbitrary size.
00588 //
00590 
00591 template<class T1, class T2, class OP, unsigned D>
00592 struct TSV_MetaBinary< AntiSymTenzor<T1,D> , AntiSymTenzor<T2,D> , OP >
00593 {
00594   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00595   inline static AntiSymTenzor<T0,D>
00596   apply(const AntiSymTenzor<T1,D>& lhs, const AntiSymTenzor<T2,D>& rhs) {
00597     AntiSymTenzor<T0,D> ret;
00598     for (unsigned d=0; d<D*(D-1)/2; ++d)
00599       ret[d] = PETE_apply(OP(),lhs[d] , rhs[d]);
00600     return ret;
00601   }
00602 };
00603 
00604 template<class T1, class T2, class OP, unsigned D>
00605 struct TSV_MetaBinaryScalar< AntiSymTenzor<T1,D> , T2 , OP >
00606 {
00607   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00608   inline static AntiSymTenzor<T0,D>
00609   apply(const AntiSymTenzor<T1,D>& lhs, T2 rhs) {
00610     AntiSymTenzor<T0,D> ret;
00611     for (unsigned d=0; d<D*(D-1)/2; ++d)
00612       ret[d] = PETE_apply( OP(), lhs[d] , rhs );
00613     return ret;
00614   }
00615 };
00616 
00617 template<class T1, class T2, class OP, unsigned D>
00618 struct TSV_MetaBinaryScalar< T1, AntiSymTenzor<T2,D> , OP >
00619 {
00620   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00621   inline static AntiSymTenzor<T0,D>
00622   apply(T1 lhs, const AntiSymTenzor<T2,D>& rhs) {
00623     AntiSymTenzor<T0,D> ret;
00624     for (unsigned d=0; d<D*(D-1)/2; ++d)
00625       ret[d] = PETE_apply( OP(), lhs , rhs[d]);
00626     return ret;
00627   }
00628 };
00629 
00631 //
00632 // Specializations of TSV_MetaBinary for AntiSymTenzors with D=1.
00633 //
00635 
00636 template<class T1, class T2, class OP>
00637 struct TSV_MetaBinary< AntiSymTenzor<T1,1> , AntiSymTenzor<T2,1> , OP >
00638 {
00639   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00640   inline static AntiSymTenzor<T0,1>
00641   apply(const AntiSymTenzor<T1,1>& lhs, const AntiSymTenzor<T2,1>& rhs) {
00642     typedef typename AntiSymTenzor<T0,1>::DontInitialize T;
00643     return AntiSymTenzor<T0,1>( T() );
00644   }
00645 };
00646 
00647 template<class T1, class T2, class OP>
00648 struct TSV_MetaBinaryScalar< AntiSymTenzor<T1,1> , T2 , OP >
00649 {
00650   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00651   inline static AntiSymTenzor<T0,1>
00652   apply(const AntiSymTenzor<T1,1>& lhs, T2 rhs) {
00653     typedef typename AntiSymTenzor<T0,1>::DontInitialize T;
00654     return AntiSymTenzor<T0,1>( T() );
00655   }
00656 };
00657 
00658 template<class T1, class T2, class OP>
00659 struct TSV_MetaBinaryScalar< T1, AntiSymTenzor<T2,1> , OP >
00660 {
00661   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00662   inline static AntiSymTenzor<T0,1>
00663   apply(T1 lhs, const AntiSymTenzor<T2,1>& rhs) {
00664     typedef typename AntiSymTenzor<T0,1>::DontInitialize T;
00665     return AntiSymTenzor<T0,1>( T() );
00666   }
00667 };
00668 
00670 //
00671 // Specializations of TSV_MetaBinary for AntiSymTenzors with D=2.
00672 //
00674 
00675 template<class T1, class T2, class OP>
00676 struct TSV_MetaBinary< AntiSymTenzor<T1,2> , AntiSymTenzor<T2,2> , OP >
00677 {
00678   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00679   inline static AntiSymTenzor<T0,2>
00680   apply(const AntiSymTenzor<T1,2>& lhs, const AntiSymTenzor<T2,2>& rhs) {
00681     return AntiSymTenzor<T0,2>( PETE_apply( OP(), lhs[0], rhs[0] ) );
00682   }
00683 };
00684 
00685 template<class T1, class T2, class OP>
00686 struct TSV_MetaBinaryScalar< AntiSymTenzor<T1,2> , T2 , OP >
00687 {
00688   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00689   inline static AntiSymTenzor<T0,2>
00690   apply(const AntiSymTenzor<T1,2>& lhs, T2 rhs) {
00691     return AntiSymTenzor<T0,2>( PETE_apply( OP(), lhs[0], rhs ) );
00692   }
00693 };
00694 
00695 template<class T1, class T2, class OP>
00696 struct TSV_MetaBinaryScalar< T1, AntiSymTenzor<T2,2> , OP >
00697 {
00698   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00699   inline static AntiSymTenzor<T0,2>
00700   apply(T1 lhs, const AntiSymTenzor<T2,2>& rhs) {
00701     return AntiSymTenzor<T0,2>( PETE_apply( OP(), lhs, rhs[0] ) );
00702   }
00703 };
00704 
00706 //
00707 // Specializations of TSV_MetaBinary for AntiSymTenzors with D=3.
00708 //
00710 
00711 template<class T1, class T2, class OP>
00712 struct TSV_MetaBinary< AntiSymTenzor<T1,3> , AntiSymTenzor<T2,3> , OP >
00713 {
00714   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00715   inline static AntiSymTenzor<T0,3>
00716   apply(const AntiSymTenzor<T1,3>& lhs, const AntiSymTenzor<T2,3>& rhs) {
00717     return AntiSymTenzor<T0,3>( PETE_apply( OP(), lhs[0], rhs[0] ) ,
00718                                 PETE_apply( OP(), lhs[1], rhs[1] ) ,
00719                                 PETE_apply( OP(), lhs[2], rhs[2] ) );
00720   }
00721 };
00722 
00723 template<class T1, class T2, class OP>
00724 struct TSV_MetaBinaryScalar< AntiSymTenzor<T1,3> , T2 , OP >
00725 {
00726   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00727   inline static AntiSymTenzor<T0,3>
00728   apply(const AntiSymTenzor<T1,3>& lhs, T2 rhs) {
00729     return AntiSymTenzor<T0,3>( PETE_apply( OP(), lhs[0], rhs ) ,
00730                                 PETE_apply( OP(), lhs[1], rhs ) ,
00731                                 PETE_apply( OP(), lhs[2], rhs ) );
00732   }
00733 };
00734 
00735 template<class T1, class T2, class OP>
00736 struct TSV_MetaBinaryScalar< T1, AntiSymTenzor<T2,3> , OP >
00737 {
00738   typedef typename PETEBinaryReturn<T1,T2,OP>::type T0;
00739   inline static AntiSymTenzor<T0,3>
00740   apply(T1 lhs, const AntiSymTenzor<T2,3>& rhs) {
00741     return AntiSymTenzor<T0,3>( PETE_apply( OP(), lhs, rhs[0] ) ,
00742                                 PETE_apply( OP(), lhs, rhs[1] ) ,
00743                                 PETE_apply( OP(), lhs, rhs[2] ) );
00744   }
00745 };
00746 
00748 
00749 #endif // TSV_META_BINARY_H
00750 
00751 /***************************************************************************
00752  * $RCSfile: TSVMetaBinary.h,v $   $Author: adelmann $
00753  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:24 $
00754  * IPPL_VERSION_ID: $Id: TSVMetaBinary.h,v 1.1.1.1 2003/01/23 07:40:24 adelmann Exp $ 
00755  ***************************************************************************/

Generated on Fri Nov 2 01:25:54 2007 for IPPL by doxygen 1.3.5