1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

integer divide

This commit is contained in:
paboyle 2015-11-28 17:00:34 -08:00
parent 113131b01c
commit fa01ae5980

View File

@ -67,6 +67,14 @@ namespace Grid {
} }
}; };
template<class scalar> struct DivIntFunctor {
Integer y;
DivIntFunctor(Integer _y) : y(_y) {};
scalar operator()(const scalar &a) const {
return Integer(a)/y;
}
};
template<class scalar> struct RealFunctor { template<class scalar> struct RealFunctor {
scalar operator()(const scalar &a) const { scalar operator()(const scalar &a) const {
return real(a); return real(a);
@ -131,6 +139,10 @@ namespace Grid {
inline Grid_simd<S,V> mod(const Grid_simd<S,V> &r,Integer y) { inline Grid_simd<S,V> mod(const Grid_simd<S,V> &r,Integer y) {
return SimdApply(ModIntFunctor<S>(y),r); return SimdApply(ModIntFunctor<S>(y),r);
} }
template < class S, class V >
inline Grid_simd<S,V> div(const Grid_simd<S,V> &r,Integer y) {
return SimdApply(DivIntFunctor<S>(y),r);
}
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Allows us to assign into **conformable** real vectors from complex // Allows us to assign into **conformable** real vectors from complex
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////