#ifndef GRID_COMPARISON_H #define GRID_COMPARISON_H namespace Grid { // Generic list of functors template class veq { public: vInteger operator()(const lobj &lhs, const robj &rhs) { return TensorRemove(lhs) == TensorRemove(rhs); } }; template class vne { public: vInteger operator()(const lobj &lhs, const robj &rhs) { return TensorRemove(lhs) != TensorRemove(rhs); } }; template class vlt { public: vInteger operator()(const lobj &lhs, const robj &rhs) { return TensorRemove(lhs) < TensorRemove(rhs); } }; template class vle { public: vInteger operator()(const lobj &lhs, const robj &rhs) { return TensorRemove(lhs) <= TensorRemove(rhs); } }; template class vgt { public: vInteger operator()(const lobj &lhs, const robj &rhs) { return TensorRemove(lhs) > TensorRemove(rhs); } }; template class vge { public: vInteger operator()(const lobj &lhs, const robj &rhs) { return TensorRemove(lhs) >= TensorRemove(rhs); } }; // Generic list of functors template class seq { public: Integer operator()(const lobj &lhs, const robj &rhs) { return TensorRemove(lhs) == TensorRemove(rhs); } }; template class sne { public: Integer operator()(const lobj &lhs, const robj &rhs) { return TensorRemove(lhs) != TensorRemove(rhs); } }; template class slt { public: Integer operator()(const lobj &lhs, const robj &rhs) { return TensorRemove(lhs) < TensorRemove(rhs); } }; template class sle { public: Integer operator()(const lobj &lhs, const robj &rhs) { return TensorRemove(lhs) <= TensorRemove(rhs); } }; template class sgt { public: Integer operator()(const lobj &lhs, const robj &rhs) { return TensorRemove(lhs) > TensorRemove(rhs); } }; template class sge { public: Integer operator()(const lobj &lhs, const robj &rhs) { return TensorRemove(lhs) >= TensorRemove(rhs); } }; ////////////////////////////////////////////////////////////////////////////////////////////////////// // Integer gets extra relational functions. Could also implement these for RealF, RealD etc.. ////////////////////////////////////////////////////////////////////////////////////////////////////// template inline vInteger Comparison(sfunctor sop,const vInteger & lhs, const vInteger & rhs) { std::vector vlhs(vInteger::Nsimd()); // Use functors to reduce this to single implementation std::vector vrhs(vInteger::Nsimd()); vInteger ret; extract(lhs,vlhs); extract(rhs,vrhs); for(int s=0;s(),lhs,rhs); } inline vInteger operator <= (const vInteger & lhs, const vInteger & rhs) { return Comparison(sle(),lhs,rhs); } inline vInteger operator > (const vInteger & lhs, const vInteger & rhs) { return Comparison(sgt(),lhs,rhs); } inline vInteger operator >= (const vInteger & lhs, const vInteger & rhs) { return Comparison(sge(),lhs,rhs); } inline vInteger operator == (const vInteger & lhs, const vInteger & rhs) { return Comparison(seq(),lhs,rhs); } inline vInteger operator != (const vInteger & lhs, const vInteger & rhs) { return Comparison(sne(),lhs,rhs); } } #include #endif