00001
00002
00003
00004
00005
00006 #ifndef TSV_META_CROSS_H
00007 #define TSV_META_CROSS_H
00008
00010
00011
00012
00014
00015 template<class T1, class T2> struct TSV_MetaCross {};
00016
00018
00019
00020
00022
00023 template<class T1, class T2, unsigned D>
00024 struct TSV_MetaCross< Vektor<T1,D> , Vektor<T2,D> >
00025 {
00026 typedef typename PETEBinaryReturn<T1,T2,OpMultipply>::type T0;
00027 inline static Vektor<T0,D>
00028 apply(const Vektor<T1,D>& a, const Vektor<T2,D>& b) {
00029 ERRORMSG("Cross-product *only* implemented for 3D; you're trying to"
00030 << " do it for " << D << "D." << endl);
00031 Ippl::abortAllNodes("...aborting from cross()");
00032 Vektor<T0,D> bogusCross(-99999);
00033 return bogusCross;
00034 }
00035 };
00036
00037 template<class T1, class T2>
00038 struct TSV_MetaCross< Vektor<T1,3> , Vektor<T2,3> >
00039 {
00040 typedef typename PETEBinaryReturn<T1,T2,OpMultipply>::type T0;
00041 inline static Vektor<T0,3>
00042 apply(const Vektor<T1,3>& a, const Vektor<T2,3>& b) {
00043 Vektor<T0,3> cross;
00044 cross[0] = a[1]*b[2] - a[2]*b[1];
00045 cross[1] = a[2]*b[0] - a[0]*b[2];
00046 cross[2] = a[0]*b[1] - a[1]*b[0];
00047 return cross;
00048 }
00049 };
00050
00052
00053 #endif // TSV_META_CROSS_H
00054
00055
00056
00057
00058
00059
00060
00061
00062