Grid 0.7.0
Tensor_logical.h
Go to the documentation of this file.
1/*************************************************************************************
2
3 Grid physics library, www.github.com/paboyle/Grid
4
5 Source file: ./lib/tensors/Tensor_logical.h
6
7 Copyright (C) 2015
8
9Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License along
22 with this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25 See the full license in the file "LICENSE" in the top level distribution directory
26*************************************************************************************/
27/* END LEGAL */
28#pragma once
29
31
32#define LOGICAL_BINOP(Op) \
33 template<class v> accelerator_inline iScalar<v> operator Op (const iScalar<v>& lhs,const iScalar<v>& rhs) \
34 { \
35 iScalar<v> ret; \
36 ret._internal = lhs._internal Op rhs._internal ; \
37 return ret; \
38 } \
39 template<class l> accelerator_inline iScalar<l> operator Op (const iScalar<l>& lhs,Integer rhs) \
40 { \
41 typename iScalar<l>::scalar_type t; t=rhs; \
42 typename iScalar<l>::tensor_reduced srhs; srhs=t; \
43 return lhs Op srhs; \
44 } \
45 template<class l> accelerator_inline iScalar<l> operator Op (Integer lhs,const iScalar<l>& rhs) \
46 { \
47 typename iScalar<l>::scalar_type t;t=lhs; \
48 typename iScalar<l>::tensor_reduced slhs;slhs=t; \
49 return slhs Op rhs; \
50 }
51
56
57template <class T>
59{
60 return (t1._internal == t2._internal);
61}
62
63template <class T, int N>
65{
66 bool res = true;
67
68 for (unsigned int i = 0; i < N; ++i)
69 {
70 res = (res && (t1._internal[i] == t2._internal[i]));
71 }
72
73 return res;
74}
75
76template <class T, int N>
78{
79 bool res = true;
80
81 for (unsigned int i = 0; i < N; ++i)
82 for (unsigned int j = 0; j < N; ++j)
83 {
84 res = (res && (t1._internal[i][j] == t2._internal[i][j]));
85 }
86
87 return res;
88}
89
91
92
#define accelerator_inline
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
accelerator_inline bool operator==(const iScalar< T > &t1, const iScalar< T > &t2)
#define LOGICAL_BINOP(Op)
vtype _internal[N][N]
vtype _internal
vtype _internal[N]