1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-11 19:57:06 +01:00

Some unary ops and coarse grid support

This commit is contained in:
Peter Boyle
2015-06-09 10:26:19 +01:00
parent f19518d564
commit 1048304f30
15 changed files with 258 additions and 48 deletions

View File

@ -90,10 +90,10 @@ public:
operator ComplexD () const { return(TensorRemove(_internal)); };
operator RealD () const { return(real(TensorRemove(_internal))); }
// convert from a something to a scalar
template<class T,typename std::enable_if<!isGridTensor<T>::value, T>::type* = nullptr > strong_inline auto operator = (T arg) -> iScalar<vtype>
// convert from a something to a scalar via constructor of something arg
template<class T,typename std::enable_if<!isGridTensor<T>::value, T>::type* = nullptr > strong_inline iScalar<vtype> operator = (T arg)
{
_internal = vtype(arg);
_internal = arg;
return *this;
}
@ -316,7 +316,8 @@ public:
stream<<o._internal[i][j];
if (i<N-1) stream<<",";
}
stream<<"}\n\t\t";
stream<<"}";
if(i!=N-1) stream<<"\n\t\t";
}
stream<<"}";
return stream;

View File

@ -27,11 +27,40 @@ template<class obj,int N> inline auto func(const iMatrix<obj,N> &z) -> iMatrix<o
return ret;\
}
#define BINARY_RSCALAR(func,scal) \
template<class obj> inline iScalar<obj> func(const iScalar<obj> &z,scal y) \
{\
iScalar<obj> ret;\
ret._internal = func(z._internal,y); \
return ret;\
}\
template<class obj,int N> inline iVector<obj,N> func(const iVector<obj,N> &z,scal y) \
{\
iVector<obj,N> ret;\
for(int c1=0;c1<N;c1++){\
ret._internal[c1] = func(z._internal[c1],y); \
}\
return ret;\
}\
template<class obj,int N> inline iMatrix<obj,N> func(const iMatrix<obj,N> &z, scal y) \
{\
iMatrix<obj,N> ret;\
for(int c1=0;c1<N;c1++){\
for(int c2=0;c2<N;c2++){\
ret._internal[c1][c2] = func(z._internal[c1][c2],y); \
}}\
return ret;\
}
UNARY_REAL(sqrt);
UNARY_REAL(rsqrt);
UNARY_REAL(sin);
UNARY_REAL(cos);
BINARY_RSCALAR(mod,Integer);
BINARY_RSCALAR(pow,RealD);
}
#endif