mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
Namespace, indent
This commit is contained in:
parent
31cbbfc07e
commit
e9ef7e3852
@ -1,4 +1,4 @@
|
|||||||
/*************************************************************************************
|
/*************************************************************************************
|
||||||
|
|
||||||
Grid physics library, www.github.com/paboyle/Grid
|
Grid physics library, www.github.com/paboyle/Grid
|
||||||
|
|
||||||
@ -23,116 +23,116 @@ Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
|||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
See the full license in the file "LICENSE" in the top level distribution directory
|
See the full license in the file "LICENSE" in the top level distribution directory
|
||||||
*************************************************************************************/
|
*************************************************************************************/
|
||||||
/* END LEGAL */
|
/* END LEGAL */
|
||||||
#ifndef GRID_LATTICE_OVERLOAD_H
|
#ifndef GRID_LATTICE_OVERLOAD_H
|
||||||
#define GRID_LATTICE_OVERLOAD_H
|
#define GRID_LATTICE_OVERLOAD_H
|
||||||
|
|
||||||
namespace Grid {
|
NAMESPACE_BEGIN(Grid);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// unary negation
|
// unary negation
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
template<class vobj>
|
template<class vobj>
|
||||||
inline Lattice<vobj> operator -(const Lattice<vobj> &r)
|
inline Lattice<vobj> operator -(const Lattice<vobj> &r)
|
||||||
{
|
{
|
||||||
Lattice<vobj> ret(r._grid);
|
Lattice<vobj> ret(r._grid);
|
||||||
parallel_for(int ss=0;ss<r._grid->oSites();ss++){
|
parallel_for(int ss=0;ss<r._grid->oSites();ss++){
|
||||||
vstream(ret._odata[ss], -r._odata[ss]);
|
vstream(ret._odata[ss], -r._odata[ss]);
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Lattice BinOp Lattice,
|
|
||||||
//NB mult performs conformable check. Do not reapply here for performance.
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
template<class left,class right>
|
|
||||||
inline auto operator * (const Lattice<left> &lhs,const Lattice<right> &rhs)-> Lattice<decltype(lhs._odata[0]*rhs._odata[0])>
|
|
||||||
{
|
|
||||||
Lattice<decltype(lhs._odata[0]*rhs._odata[0])> ret(rhs._grid);
|
|
||||||
mult(ret,lhs,rhs);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
template<class left,class right>
|
return ret;
|
||||||
inline auto operator + (const Lattice<left> &lhs,const Lattice<right> &rhs)-> Lattice<decltype(lhs._odata[0]+rhs._odata[0])>
|
}
|
||||||
{
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
Lattice<decltype(lhs._odata[0]+rhs._odata[0])> ret(rhs._grid);
|
// Lattice BinOp Lattice,
|
||||||
add(ret,lhs,rhs);
|
//NB mult performs conformable check. Do not reapply here for performance.
|
||||||
return ret;
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
}
|
template<class left,class right>
|
||||||
template<class left,class right>
|
inline auto operator * (const Lattice<left> &lhs,const Lattice<right> &rhs)-> Lattice<decltype(lhs._odata[0]*rhs._odata[0])>
|
||||||
inline auto operator - (const Lattice<left> &lhs,const Lattice<right> &rhs)-> Lattice<decltype(lhs._odata[0]-rhs._odata[0])>
|
{
|
||||||
{
|
Lattice<decltype(lhs._odata[0]*rhs._odata[0])> ret(rhs._grid);
|
||||||
Lattice<decltype(lhs._odata[0]-rhs._odata[0])> ret(rhs._grid);
|
mult(ret,lhs,rhs);
|
||||||
sub(ret,lhs,rhs);
|
return ret;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scalar BinOp Lattice ;generate return type
|
|
||||||
template<class left,class right>
|
|
||||||
inline auto operator * (const left &lhs,const Lattice<right> &rhs) -> Lattice<decltype(lhs*rhs._odata[0])>
|
|
||||||
{
|
|
||||||
Lattice<decltype(lhs*rhs._odata[0])> ret(rhs._grid);
|
|
||||||
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
|
||||||
decltype(lhs*rhs._odata[0]) tmp=lhs*rhs._odata[ss];
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
// ret._odata[ss]=lhs*rhs._odata[ss];
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
template<class left,class right>
|
|
||||||
inline auto operator + (const left &lhs,const Lattice<right> &rhs) -> Lattice<decltype(lhs+rhs._odata[0])>
|
|
||||||
{
|
|
||||||
Lattice<decltype(lhs+rhs._odata[0])> ret(rhs._grid);
|
|
||||||
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
|
||||||
decltype(lhs+rhs._odata[0]) tmp =lhs-rhs._odata[ss];
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
// ret._odata[ss]=lhs+rhs._odata[ss];
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
template<class left,class right>
|
|
||||||
inline auto operator - (const left &lhs,const Lattice<right> &rhs) -> Lattice<decltype(lhs-rhs._odata[0])>
|
|
||||||
{
|
|
||||||
Lattice<decltype(lhs-rhs._odata[0])> ret(rhs._grid);
|
|
||||||
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
|
||||||
decltype(lhs-rhs._odata[0]) tmp=lhs-rhs._odata[ss];
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
template<class left,class right>
|
|
||||||
inline auto operator * (const Lattice<left> &lhs,const right &rhs) -> Lattice<decltype(lhs._odata[0]*rhs)>
|
|
||||||
{
|
|
||||||
Lattice<decltype(lhs._odata[0]*rhs)> ret(lhs._grid);
|
|
||||||
parallel_for(int ss=0;ss<lhs._grid->oSites(); ss++){
|
|
||||||
decltype(lhs._odata[0]*rhs) tmp =lhs._odata[ss]*rhs;
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
// ret._odata[ss]=lhs._odata[ss]*rhs;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
template<class left,class right>
|
|
||||||
inline auto operator + (const Lattice<left> &lhs,const right &rhs) -> Lattice<decltype(lhs._odata[0]+rhs)>
|
|
||||||
{
|
|
||||||
Lattice<decltype(lhs._odata[0]+rhs)> ret(lhs._grid);
|
|
||||||
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
|
||||||
decltype(lhs._odata[0]+rhs) tmp=lhs._odata[ss]+rhs;
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
// ret._odata[ss]=lhs._odata[ss]+rhs;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
template<class left,class right>
|
|
||||||
inline auto operator - (const Lattice<left> &lhs,const right &rhs) -> Lattice<decltype(lhs._odata[0]-rhs)>
|
|
||||||
{
|
|
||||||
Lattice<decltype(lhs._odata[0]-rhs)> ret(lhs._grid);
|
|
||||||
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
|
||||||
decltype(lhs._odata[0]-rhs) tmp=lhs._odata[ss]-rhs;
|
|
||||||
vstream(ret._odata[ss],tmp);
|
|
||||||
// ret._odata[ss]=lhs._odata[ss]-rhs;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
template<class left,class right>
|
||||||
|
inline auto operator + (const Lattice<left> &lhs,const Lattice<right> &rhs)-> Lattice<decltype(lhs._odata[0]+rhs._odata[0])>
|
||||||
|
{
|
||||||
|
Lattice<decltype(lhs._odata[0]+rhs._odata[0])> ret(rhs._grid);
|
||||||
|
add(ret,lhs,rhs);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
template<class left,class right>
|
||||||
|
inline auto operator - (const Lattice<left> &lhs,const Lattice<right> &rhs)-> Lattice<decltype(lhs._odata[0]-rhs._odata[0])>
|
||||||
|
{
|
||||||
|
Lattice<decltype(lhs._odata[0]-rhs._odata[0])> ret(rhs._grid);
|
||||||
|
sub(ret,lhs,rhs);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scalar BinOp Lattice ;generate return type
|
||||||
|
template<class left,class right>
|
||||||
|
inline auto operator * (const left &lhs,const Lattice<right> &rhs) -> Lattice<decltype(lhs*rhs._odata[0])>
|
||||||
|
{
|
||||||
|
Lattice<decltype(lhs*rhs._odata[0])> ret(rhs._grid);
|
||||||
|
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
||||||
|
decltype(lhs*rhs._odata[0]) tmp=lhs*rhs._odata[ss];
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
// ret._odata[ss]=lhs*rhs._odata[ss];
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
template<class left,class right>
|
||||||
|
inline auto operator + (const left &lhs,const Lattice<right> &rhs) -> Lattice<decltype(lhs+rhs._odata[0])>
|
||||||
|
{
|
||||||
|
Lattice<decltype(lhs+rhs._odata[0])> ret(rhs._grid);
|
||||||
|
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
||||||
|
decltype(lhs+rhs._odata[0]) tmp =lhs-rhs._odata[ss];
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
// ret._odata[ss]=lhs+rhs._odata[ss];
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
template<class left,class right>
|
||||||
|
inline auto operator - (const left &lhs,const Lattice<right> &rhs) -> Lattice<decltype(lhs-rhs._odata[0])>
|
||||||
|
{
|
||||||
|
Lattice<decltype(lhs-rhs._odata[0])> ret(rhs._grid);
|
||||||
|
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
||||||
|
decltype(lhs-rhs._odata[0]) tmp=lhs-rhs._odata[ss];
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
template<class left,class right>
|
||||||
|
inline auto operator * (const Lattice<left> &lhs,const right &rhs) -> Lattice<decltype(lhs._odata[0]*rhs)>
|
||||||
|
{
|
||||||
|
Lattice<decltype(lhs._odata[0]*rhs)> ret(lhs._grid);
|
||||||
|
parallel_for(int ss=0;ss<lhs._grid->oSites(); ss++){
|
||||||
|
decltype(lhs._odata[0]*rhs) tmp =lhs._odata[ss]*rhs;
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
// ret._odata[ss]=lhs._odata[ss]*rhs;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
template<class left,class right>
|
||||||
|
inline auto operator + (const Lattice<left> &lhs,const right &rhs) -> Lattice<decltype(lhs._odata[0]+rhs)>
|
||||||
|
{
|
||||||
|
Lattice<decltype(lhs._odata[0]+rhs)> ret(lhs._grid);
|
||||||
|
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
||||||
|
decltype(lhs._odata[0]+rhs) tmp=lhs._odata[ss]+rhs;
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
// ret._odata[ss]=lhs._odata[ss]+rhs;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
template<class left,class right>
|
||||||
|
inline auto operator - (const Lattice<left> &lhs,const right &rhs) -> Lattice<decltype(lhs._odata[0]-rhs)>
|
||||||
|
{
|
||||||
|
Lattice<decltype(lhs._odata[0]-rhs)> ret(lhs._grid);
|
||||||
|
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
||||||
|
decltype(lhs._odata[0]-rhs) tmp=lhs._odata[ss]-rhs;
|
||||||
|
vstream(ret._odata[ss],tmp);
|
||||||
|
// ret._odata[ss]=lhs._odata[ss]-rhs;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
NAMESPACE_END(Grid);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user