OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
TSVMetaCompare.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  *
7  * Visit http://people.web.psi.ch/adelmann/ for more details
8  *
9  ***************************************************************************/
10 
11 #ifndef TSV_META_COMPARE_H
12 #define TSV_META_COMPARE_H
13 
15 //
16 // The definition for arrays of arbitrary size.
17 //
19 
20 template<class T1, class T2, unsigned D>
22 {
23  inline static bool
24  apply(const T1* lhs, const T2* rhs) {
25  for (unsigned int i = 0; i < D; i++)
26  if (lhs[i] != rhs[i])
27  return false;
28  return true;
29  }
30 };
31 
32 
34 //
35 // The default definition for the template TSV_MetaCompare;
36 //
38 
39 template<class T1, class T2> struct TSV_MetaCompare {};
40 
42 //
43 // Specialization for Vektors of arbitrary size.
44 //
46 
47 template<class T1, class T2, unsigned D>
48 struct TSV_MetaCompare< Vektor<T1,D> , Vektor<T2,D> >
49 {
50  inline static bool
51  apply(const Vektor<T1,D>& lhs, const Vektor<T2,D>& rhs) {
52  return TSV_MetaCompareArrays<T1,T2,D>::apply(&lhs[0],&rhs[0]);
53  }
54 };
55 
57 //
58 // Specialization for Tenzors of arbitrary size.
59 //
61 
62 template<class T1, class T2, unsigned D>
63 struct TSV_MetaCompare< Tenzor<T1,D> , Tenzor<T2,D> >
64 {
65  inline static bool
66  apply(const Tenzor<T1,D>& lhs, const Tenzor<T2,D>& rhs) {
67  return TSV_MetaCompareArrays<T1,T2,D*D>::apply(&lhs[0],&rhs[0]);
68  }
69 };
70 
72 //
73 // Specialization for SymTenzors of arbitrary size.
74 //
76 
77 template<class T1, class T2, unsigned D>
78 struct TSV_MetaCompare< SymTenzor<T1,D> , SymTenzor<T2,D> >
79 {
80  inline static bool
81  apply(const SymTenzor<T1,D>& lhs, const SymTenzor<T2,D>& rhs) {
82  return TSV_MetaCompareArrays<T1,T2,D*(D+1)/2>::apply(&lhs[0],&rhs[0]);
83  }
84 };
85 
87 //
88 // Specialization for AntiSymTenzors of arbitrary size.
89 //
91 
92 template<class T1, class T2, unsigned D>
94 {
95  inline static bool
96  apply(const AntiSymTenzor<T1,D>& lhs, const AntiSymTenzor<T2,D>& rhs) {
97  return TSV_MetaCompareArrays<T1,T2,D*(D-1)/2>::apply(&lhs[0],&rhs[0]);
98  }
99 };
100 
102 
103 #endif // TSV_META_COMPARE_H
104 
105 /***************************************************************************
106  * $RCSfile: TSVMetaCompare.h,v $ $Author: adelmann $
107  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:24 $
108  * IPPL_VERSION_ID: $Id: TSVMetaCompare.h,v 1.1.1.1 2003/01/23 07:40:24 adelmann Exp $
109  ***************************************************************************/
110 
Definition: Tenzor.h:35
Definition: Vektor.h:32
static bool apply(const T1 *lhs, const T2 *rhs)
static bool apply(const Vektor< T1, D > &lhs, const Vektor< T2, D > &rhs)
static bool apply(const Tenzor< T1, D > &lhs, const Tenzor< T2, D > &rhs)
static bool apply(const SymTenzor< T1, D > &lhs, const SymTenzor< T2, D > &rhs)
static bool apply(const AntiSymTenzor< T1, D > &lhs, const AntiSymTenzor< T2, D > &rhs)