Grid 0.7.0
Tensor_reality.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_reality.h
6
7 Copyright (C) 2015
8
9Author: Peter Boyle <paboyle@ph.ed.ac.uk>
10Author: neo <cossu@post.kek.jp>
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License along
23 with this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
26 See the full license in the file "LICENSE" in the top level distribution directory
27*************************************************************************************/
28/* END LEGAL */
29#ifndef GRID_MATH_REALITY_H
30#define GRID_MATH_REALITY_H
31
33
35// multiply by I; make recursive.
38{
41 return ret;
42}
43template<class vtype,int N> accelerator_inline iVector<vtype,N> timesI(const iVector<vtype,N>&r)
44{
46 for(int i=0;i<N;i++){
47 timesI(ret._internal[i],r._internal[i]);
48 }
49 return ret;
50}
51template<class vtype,int N> accelerator_inline iMatrix<vtype,N> timesI(const iMatrix<vtype,N>&r)
52{
54 for(int i=0;i<N;i++){
55 for(int j=0;j<N;j++){
56 timesI(ret._internal[i][j],r._internal[i][j]);
57 }}
58 return ret;
59}
60
61template<class vtype> accelerator_inline void timesI(iScalar<vtype> &ret,const iScalar<vtype>&r)
62{
64}
65template<class vtype,int N> accelerator_inline void timesI(iVector<vtype,N> &ret,const iVector<vtype,N>&r)
66{
67 for(int i=0;i<N;i++){
68 timesI(ret._internal[i],r._internal[i]);
69 }
70}
71template<class vtype,int N> accelerator_inline void timesI(iMatrix<vtype,N> &ret,const iMatrix<vtype,N>&r)
72{
73 for(int i=0;i<N;i++){
74 for(int j=0;j<N;j++){
75 timesI(ret._internal[i][j],r._internal[i][j]);
76 }}
77}
78
79
81{
84 return ret;
85}
87{
89 for(int i=0;i<N;i++){
90 timesMinusI(ret._internal[i],r._internal[i]);
91 }
92 return ret;
93}
95{
97 for(int i=0;i<N;i++){
98 for(int j=0;j<N;j++){
99 timesMinusI(ret._internal[i][j],r._internal[i][j]);
100 }}
101 return ret;
102}
103
104template<class vtype> accelerator_inline void timesMinusI(iScalar<vtype> &ret,const iScalar<vtype>&r)
105{
107}
108template<class vtype,int N> accelerator_inline void timesMinusI(iVector<vtype,N> &ret,const iVector<vtype,N>&r)
109{
110 for(int i=0;i<N;i++){
111 timesMinusI(ret._internal[i],r._internal[i]);
112 }
113}
114template<class vtype,int N> accelerator_inline void timesMinusI(iMatrix<vtype,N> &ret,const iMatrix<vtype,N>&r)
115{
116 for(int i=0;i<N;i++){
117 for(int j=0;j<N;j++){
118 timesMinusI(ret._internal[i][j],r._internal[i][j]);
119 }}
120}
121
122
124// Conj function for scalar, vector, matrix
127{
128 iScalar<vtype> ret;
130 return ret;
131}
133{
135 for(int i=0;i<N;i++){
136 ret._internal[i] = conjugate(r._internal[i]);
137 }
138 return ret;
139}
141{
143 for(int i=0;i<N;i++){
144 for(int j=0;j<N;j++){
145 ret._internal[i][j] = conjugate(r._internal[i][j]);
146 }}
147 return ret;
148}
149
151// Adj function for scalar, vector, matrix
154{
155 iScalar<vtype> ret;
156 ret._internal = adj(r._internal);
157 return ret;
158}
159template<class vtype,int N> accelerator_inline iVector<vtype,N> adj(const iVector<vtype,N>&r)
160{
162 for(int i=0;i<N;i++){
163 ret._internal[i] = adj(r._internal[i]);
164 }
165 return ret;
166}
167template<class vtype,int N> accelerator_inline iMatrix<vtype,N> adj(const iMatrix<vtype,N> &arg)
168{
170 for(int c1=0;c1<N;c1++){
171 for(int c2=0;c2<N;c2++){
172 ret._internal[c1][c2]=adj(arg._internal[c2][c1]);
173 }}
174 return ret;
175}
176
177
178
179
180
181
183// Can only take the real/imag part of scalar objects, since
184// lattice objects of different complex nature are non-conformable.
186template<class itype> accelerator_inline auto real(const iScalar<itype> &z) -> iScalar<decltype(real(z._internal))>
187{
188 iScalar<decltype(real(z._internal))> ret;
189 ret._internal = real(z._internal);
190 return ret;
191}
192template<class itype,int N> accelerator_inline auto real(const iMatrix<itype,N> &z) -> iMatrix<decltype(real(z._internal[0][0])),N>
193{
194 iMatrix<decltype(real(z._internal[0][0])),N> ret;
195 for(int c1=0;c1<N;c1++){
196 for(int c2=0;c2<N;c2++){
197 ret._internal[c1][c2] = real(z._internal[c1][c2]);
198 }}
199 return ret;
200}
201template<class itype,int N> accelerator_inline auto real(const iVector<itype,N> &z) -> iVector<decltype(real(z._internal[0])),N>
202{
203 iVector<decltype(real(z._internal[0])),N> ret;
204 for(int c1=0;c1<N;c1++){
205 ret._internal[c1] = real(z._internal[c1]);
206 }
207 return ret;
208}
209
210template<class itype> accelerator_inline auto imag(const iScalar<itype> &z) -> iScalar<decltype(imag(z._internal))>
211{
212 iScalar<decltype(imag(z._internal))> ret;
213 ret._internal = imag(z._internal);
214 return ret;
215}
216template<class itype,int N> accelerator_inline auto imag(const iMatrix<itype,N> &z) -> iMatrix<decltype(imag(z._internal[0][0])),N>
217{
218 iMatrix<decltype(imag(z._internal[0][0])),N> ret;
219 for(int c1=0;c1<N;c1++){
220 for(int c2=0;c2<N;c2++){
221 ret._internal[c1][c2] = imag(z._internal[c1][c2]);
222 }}
223 return ret;
224}
225template<class itype,int N> accelerator_inline auto imag(const iVector<itype,N> &z) -> iVector<decltype(imag(z._internal[0])),N>
226{
227 iVector<decltype(imag(z._internal[0])),N> ret;
228 for(int c1=0;c1<N;c1++){
229 ret._internal[c1] = imag(z._internal[c1]);
230 }
231 return ret;
232}
233
235
236#endif
#define accelerator_inline
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
accelerator_inline iScalar< vtype > timesMinusI(const iScalar< vtype > &r)
accelerator_inline auto real(const iScalar< itype > &z) -> iScalar< decltype(real(z._internal))>
accelerator_inline auto imag(const iScalar< itype > &z) -> iScalar< decltype(imag(z._internal))>
accelerator_inline iScalar< vtype > conjugate(const iScalar< vtype > &r)
accelerator_inline iScalar< vtype > timesI(const iScalar< vtype > &r)
accelerator_inline iScalar< vtype > adj(const iScalar< vtype > &r)
vtype _internal[N][N]
vtype _internal
vtype _internal[N]