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

src/AppTypes/TSVMetaCross.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //-----------------------------------------------------------------------------
00003 // The IPPL Framework - Visit http://people.web.psi.ch/adelmann/ for more details
00004 //
00005 // This program was prepared by the Regents of the University of California at
00006 #ifndef TSV_META_CROSS_H
00007 #define TSV_META_CROSS_H
00008 
00010 //
00011 // Definition of the struct TSV_MetaCross.
00012 //
00014 
00015 template<class T1, class T2> struct TSV_MetaCross {};
00016 
00018 //
00019 // Specializations for Vektor cross Vektor
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 // $(Id)
00056 
00057 /***************************************************************************
00058  * $RCSfile: addheaderfooter,v $   $Author: adelmann $
00059  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:17 $
00060  * IPPL_VERSION_ID: $Id: addheaderfooter,v 1.1.1.1 2003/01/23 07:40:17 adelmann Exp $ 
00061  ***************************************************************************/
00062 

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