Grid
0.7.0
Tensor_arith_mac.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_arith_mac.h
6
7
Copyright (C) 2015
8
9
Author: Peter Boyle <paboyle@ph.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
#ifndef GRID_MATH_ARITH_MAC_H
29
#define GRID_MATH_ARITH_MAC_H
30
31
NAMESPACE_BEGIN
(
Grid
);
32
37
39
// Legal multiplication table
41
// scal x scal = scal
42
// mat x mat = mat
43
// mat x scal = mat
44
// scal x mat = mat
45
// mat x vec = vec
46
// vec x scal = vec
47
// scal x vec = vec
49
template
<
class
rtype,
class
vtype,
class
mtype>
50
accelerator_inline
void
mac
(
iScalar<rtype>
* __restrict__ ret,
const
iScalar<vtype>
* __restrict__ lhs,
const
iScalar<mtype>
* __restrict__ rhs)
51
{
52
mac
(&ret->
_internal
,&lhs->
_internal
,&rhs->
_internal
);
53
}
54
template
<
class
rrtype,
class
ltype,
class
rtype,
int
N>
55
accelerator_inline
void
mac
(
iMatrix<rrtype,N>
* __restrict__ ret,
const
iMatrix<ltype,N>
* __restrict__ lhs,
const
iMatrix<rtype,N>
* __restrict__ rhs){
56
for
(
int
c3=0;c3<N;c3++){
57
for
(
int
c1=0;c1<N;c1++){
58
for
(
int
c2=0;c2<N;c2++){
59
mac
(&ret->
_internal
[c1][c2],&lhs->
_internal
[c1][c3],&rhs->
_internal
[c3][c2]);
60
}}}
61
return
;
62
}
63
64
template
<
class
rrtype,
class
ltype,
class
rtype,
int
N>
65
accelerator_inline
void
mac
(
iMatrix<rrtype,N>
* __restrict__ ret,
const
iMatrix<ltype,N>
* __restrict__ lhs,
const
iScalar<rtype>
* __restrict__ rhs){
66
for
(
int
c1=0;c1<N;c1++){
67
for
(
int
c2=0;c2<N;c2++){
68
mac
(&ret->
_internal
[c1][c2],&lhs->
_internal
[c1][c2],&rhs->
_internal
);
69
}}
70
return
;
71
}
72
template
<
class
rrtype,
class
ltype,
class
rtype,
int
N>
73
accelerator_inline
void
mac
(
iMatrix<rrtype,N>
* __restrict__ ret,
const
iScalar<ltype>
* __restrict__ lhs,
const
iMatrix<rtype,N>
* __restrict__ rhs){
74
for
(
int
c1=0;c1<N;c1++){
75
for
(
int
c2=0;c2<N;c2++){
76
mac
(&ret->
_internal
[c1][c2],&lhs->
_internal
,&rhs->
_internal
[c1][c2]);
77
}}
78
return
;
79
}
80
template
<
class
rrtype,
class
ltype,
class
rtype,
int
N>
81
accelerator_inline
void
mac
(
iVector<rrtype,N>
* __restrict__ ret,
const
iMatrix<ltype,N>
* __restrict__ lhs,
const
iVector<rtype,N>
* __restrict__ rhs)
82
{
83
for
(
int
c1=0;c1<N;c1++){
84
for
(
int
c2=0;c2<N;c2++){
85
mac
(&ret->
_internal
[c1],&lhs->
_internal
[c1][c2],&rhs->
_internal
[c2]);
86
}}
87
return
;
88
}
89
template
<
class
rrtype,
class
ltype,
class
rtype,
int
N>
90
accelerator_inline
void
mac
(
iVector<rrtype,N>
* __restrict__ ret,
const
iScalar<ltype>
* __restrict__ lhs,
const
iVector<rtype,N>
* __restrict__ rhs)
91
{
92
for
(
int
c1=0;c1<N;c1++){
93
mac
(&ret->
_internal
[c1],&lhs->
_internal
,&rhs->
_internal
[c1]);
94
}
95
return
;
96
}
97
template
<
class
rrtype,
class
ltype,
class
rtype,
int
N>
98
accelerator_inline
void
mac
(
iVector<rrtype,N>
* __restrict__ ret,
const
iVector<ltype,N>
* __restrict__ lhs,
const
iScalar<rtype>
* __restrict__ rhs)
99
{
100
for
(
int
c1=0;c1<N;c1++){
101
mac
(&ret->
_internal
[c1],&lhs->
_internal
[c1],&rhs->
_internal
);
102
}
103
return
;
104
}
105
NAMESPACE_END
(
Grid
);
106
107
108
#endif
accelerator_inline
#define accelerator_inline
Definition
Accelerator.h:608
NAMESPACE_BEGIN
#define NAMESPACE_BEGIN(A)
Definition
Namespace.h:35
NAMESPACE_END
#define NAMESPACE_END(A)
Definition
Namespace.h:36
mac
accelerator_inline void mac(iScalar< rtype > *__restrict__ ret, const iScalar< vtype > *__restrict__ lhs, const iScalar< mtype > *__restrict__ rhs)
Definition
Tensor_arith_mac.h:50
iMatrix
Definition
Tensor_class.h:301
iMatrix::_internal
vtype _internal[N][N]
Definition
Tensor_class.h:303
iScalar
Definition
Tensor_class.h:77
iScalar::_internal
vtype _internal
Definition
Tensor_class.h:79
iVector
Definition
Tensor_class.h:189
iVector::_internal
vtype _internal[N]
Definition
Tensor_class.h:191
Grid
Definition
Deflation.h:31
Grid
tensors
Tensor_arith_mac.h
Generated by
1.16.1