mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-10 06:00:45 +01:00
Namespce,and indent
This commit is contained in:
parent
88e635c5d1
commit
edb79dc088
@ -1,4 +1,4 @@
|
|||||||
/*************************************************************************************
|
/*************************************************************************************
|
||||||
|
|
||||||
Grid physics library, www.github.com/paboyle/Grid
|
Grid physics library, www.github.com/paboyle/Grid
|
||||||
|
|
||||||
@ -24,146 +24,146 @@ 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_COMPARISON_H
|
#ifndef GRID_LATTICE_COMPARISON_H
|
||||||
#define GRID_LATTICE_COMPARISON_H
|
#define GRID_LATTICE_COMPARISON_H
|
||||||
|
|
||||||
namespace Grid {
|
NAMESPACE_BEGIN(Grid);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// relational operators
|
// relational operators
|
||||||
//
|
//
|
||||||
// Support <,>,<=,>=,==,!=
|
// Support <,>,<=,>=,==,!=
|
||||||
//
|
//
|
||||||
//Query supporting bitwise &, |, ^, !
|
//Query supporting bitwise &, |, ^, !
|
||||||
//Query supporting logical &&, ||,
|
//Query supporting logical &&, ||,
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// compare lattice to lattice
|
// compare lattice to lattice
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
template<class vfunctor,class lobj,class robj>
|
template<class vfunctor,class lobj,class robj>
|
||||||
inline Lattice<vInteger> LLComparison(vfunctor op,const Lattice<lobj> &lhs,const Lattice<robj> &rhs)
|
inline Lattice<vInteger> LLComparison(vfunctor op,const Lattice<lobj> &lhs,const Lattice<robj> &rhs)
|
||||||
{
|
{
|
||||||
Lattice<vInteger> ret(rhs._grid);
|
Lattice<vInteger> ret(rhs._grid);
|
||||||
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
||||||
ret._odata[ss]=op(lhs._odata[ss],rhs._odata[ss]);
|
ret._odata[ss]=op(lhs._odata[ss],rhs._odata[ss]);
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
//////////////////////////////////////////////////////////////////////////
|
return ret;
|
||||||
// compare lattice to scalar
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
template<class vfunctor,class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> LSComparison(vfunctor op,const Lattice<lobj> &lhs,const robj &rhs)
|
|
||||||
{
|
|
||||||
Lattice<vInteger> ret(lhs._grid);
|
|
||||||
parallel_for(int ss=0;ss<lhs._grid->oSites(); ss++){
|
|
||||||
ret._odata[ss]=op(lhs._odata[ss],rhs);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// compare scalar to lattice
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
template<class vfunctor,class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> SLComparison(vfunctor op,const lobj &lhs,const Lattice<robj> &rhs)
|
|
||||||
{
|
|
||||||
Lattice<vInteger> ret(rhs._grid);
|
|
||||||
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
|
||||||
ret._odata[ss]=op(lhs._odata[ss],rhs);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// Map to functors
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// Less than
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator < (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return LLComparison(vlt<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator < (const Lattice<lobj> & lhs, const robj & rhs) {
|
|
||||||
return LSComparison(vlt<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator < (const lobj & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return SLComparison(vlt<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Less than equal
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator <= (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return LLComparison(vle<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator <= (const Lattice<lobj> & lhs, const robj & rhs) {
|
|
||||||
return LSComparison(vle<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator <= (const lobj & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return SLComparison(vle<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Greater than
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator > (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return LLComparison(vgt<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator > (const Lattice<lobj> & lhs, const robj & rhs) {
|
|
||||||
return LSComparison(vgt<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator > (const lobj & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return SLComparison(vgt<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Greater than equal
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator >= (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return LLComparison(vge<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator >= (const Lattice<lobj> & lhs, const robj & rhs) {
|
|
||||||
return LSComparison(vge<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator >= (const lobj & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return SLComparison(vge<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// equal
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator == (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return LLComparison(veq<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator == (const Lattice<lobj> & lhs, const robj & rhs) {
|
|
||||||
return LSComparison(veq<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator == (const lobj & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return SLComparison(veq<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// not equal
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator != (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return LLComparison(vne<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator != (const Lattice<lobj> & lhs, const robj & rhs) {
|
|
||||||
return LSComparison(vne<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator != (const lobj & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return SLComparison(vne<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// compare lattice to scalar
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class vfunctor,class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> LSComparison(vfunctor op,const Lattice<lobj> &lhs,const robj &rhs)
|
||||||
|
{
|
||||||
|
Lattice<vInteger> ret(lhs._grid);
|
||||||
|
parallel_for(int ss=0;ss<lhs._grid->oSites(); ss++){
|
||||||
|
ret._odata[ss]=op(lhs._odata[ss],rhs);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// compare scalar to lattice
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class vfunctor,class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> SLComparison(vfunctor op,const lobj &lhs,const Lattice<robj> &rhs)
|
||||||
|
{
|
||||||
|
Lattice<vInteger> ret(rhs._grid);
|
||||||
|
parallel_for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
||||||
|
ret._odata[ss]=op(lhs._odata[ss],rhs);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Map to functors
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Less than
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator < (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return LLComparison(vlt<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator < (const Lattice<lobj> & lhs, const robj & rhs) {
|
||||||
|
return LSComparison(vlt<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator < (const lobj & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return SLComparison(vlt<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Less than equal
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator <= (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return LLComparison(vle<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator <= (const Lattice<lobj> & lhs, const robj & rhs) {
|
||||||
|
return LSComparison(vle<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator <= (const lobj & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return SLComparison(vle<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Greater than
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator > (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return LLComparison(vgt<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator > (const Lattice<lobj> & lhs, const robj & rhs) {
|
||||||
|
return LSComparison(vgt<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator > (const lobj & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return SLComparison(vgt<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Greater than equal
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator >= (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return LLComparison(vge<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator >= (const Lattice<lobj> & lhs, const robj & rhs) {
|
||||||
|
return LSComparison(vge<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator >= (const lobj & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return SLComparison(vge<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// equal
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator == (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return LLComparison(veq<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator == (const Lattice<lobj> & lhs, const robj & rhs) {
|
||||||
|
return LSComparison(veq<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator == (const lobj & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return SLComparison(veq<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// not equal
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator != (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return LLComparison(vne<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator != (const Lattice<lobj> & lhs, const robj & rhs) {
|
||||||
|
return LSComparison(vne<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator != (const lobj & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return SLComparison(vne<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
NAMESPACE_END(Grid);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user