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

src/AppTypes/TSVMetaCompare.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_COMPARE_H
00012 #define TSV_META_COMPARE_H
00013 
00015 //
00016 // The definition for arrays of arbitrary size.
00017 //
00019 
00020 template<class T1, class T2, unsigned D>
00021 struct TSV_MetaCompareArrays
00022 {
00023   inline static bool
00024   apply(const T1* lhs, const T2* rhs) {
00025     for (int i = 0; i < D; i++)
00026       if (lhs[i] != rhs[i])
00027         return false;
00028     return true;
00029   }
00030 };
00031 
00032 
00034 //
00035 // The default definition for the template TSV_MetaCompare;
00036 //
00038 
00039 template<class T1, class T2> struct TSV_MetaCompare {};
00040 
00042 //
00043 // Specialization for Vektors of arbitrary size.
00044 //
00046 
00047 template<class T1, class T2, unsigned D>
00048 struct TSV_MetaCompare< Vektor<T1,D> , Vektor<T2,D> >
00049 {
00050   inline static bool
00051   apply(const Vektor<T1,D>& lhs, const Vektor<T2,D>& rhs) {
00052     return TSV_MetaCompareArrays<T1,T2,D>::apply(&lhs[0],&rhs[0]);
00053   }
00054 };
00055 
00057 //
00058 // Specialization for Tenzors of arbitrary size.
00059 //
00061 
00062 template<class T1, class T2, unsigned D>
00063 struct TSV_MetaCompare< Tenzor<T1,D> , Tenzor<T2,D> >
00064 {
00065   inline static bool
00066   apply(const Tenzor<T1,D>& lhs, const Tenzor<T2,D>& rhs) {
00067     return TSV_MetaCompareArrays<T1,T2,D*D>::apply(&lhs[0],&rhs[0]);
00068   }
00069 };
00070 
00072 //
00073 // Specialization for SymTenzors of arbitrary size.
00074 //
00076 
00077 template<class T1, class T2, unsigned D>
00078 struct TSV_MetaCompare< SymTenzor<T1,D> , SymTenzor<T2,D> >
00079 {
00080   inline static bool
00081   apply(const SymTenzor<T1,D>& lhs, const SymTenzor<T2,D>& rhs) {
00082     return TSV_MetaCompareArrays<T1,T2,D*(D+1)/2>::apply(&lhs[0],&rhs[0]);
00083   }
00084 };
00085 
00087 //
00088 // Specialization for AntiSymTenzors of arbitrary size.
00089 //
00091 
00092 template<class T1, class T2, unsigned D>
00093 struct TSV_MetaCompare< AntiSymTenzor<T1,D> , AntiSymTenzor<T2,D> >
00094 {
00095   inline static bool
00096   apply(const AntiSymTenzor<T1,D>& lhs, const AntiSymTenzor<T2,D>& rhs) {
00097     return TSV_MetaCompareArrays<T1,T2,D*(D-1)/2>::apply(&lhs[0],&rhs[0]);
00098   }
00099 };
00100 
00102 
00103 #endif // TSV_META_COMPARE_H
00104 
00105 /***************************************************************************
00106  * $RCSfile: TSVMetaCompare.h,v $   $Author: adelmann $
00107  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:24 $
00108  * IPPL_VERSION_ID: $Id: TSVMetaCompare.h,v 1.1.1.1 2003/01/23 07:40:24 adelmann Exp $ 
00109  ***************************************************************************/
00110 

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