1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-07-25 17:07:07 +01:00

Merge branch 'feature/parallelio' into develop

This commit is contained in:
paboyle
2017-06-19 01:39:48 +01:00
53 changed files with 2364 additions and 1346 deletions

View File

@@ -47,6 +47,28 @@ template<int Level>
class TensorIndexRecursion {
public:
////////////////////////////////////////////////////
// Type Queries
////////////////////////////////////////////////////
template<class vtype> static inline int indexRank(const iScalar<vtype> tmp) { return TensorIndexRecursion<Level-1>::indexRank(tmp._internal); }
template<class vtype,int N> static inline int indexRank(const iVector<vtype,N> tmp){ return TensorIndexRecursion<Level-1>::indexRank(tmp._internal[0]); }
template<class vtype,int N> static inline int indexRank(const iMatrix<vtype,N> tmp){ return TensorIndexRecursion<Level-1>::indexRank(tmp._internal[0][0]); }
template<class vtype> static inline int isScalar(const iScalar<vtype> tmp) { return TensorIndexRecursion<Level-1>::isScalar(tmp._internal); }
template<class vtype,int N> static inline int isScalar(const iVector<vtype,N> tmp){ return TensorIndexRecursion<Level-1>::isScalar(tmp._internal[0]); }
template<class vtype,int N> static inline int isScalar(const iMatrix<vtype,N> tmp){ return TensorIndexRecursion<Level-1>::isScalar(tmp._internal[0][0]); }
template<class vtype> static inline int isVector(const iScalar<vtype> tmp) { return TensorIndexRecursion<Level-1>::isVector(tmp._internal); }
template<class vtype,int N> static inline int isVector(const iVector<vtype,N> tmp){ return TensorIndexRecursion<Level-1>::isVector(tmp._internal[0]); }
template<class vtype,int N> static inline int isVector(const iMatrix<vtype,N> tmp){ return TensorIndexRecursion<Level-1>::isVector(tmp._internal[0][0]); }
template<class vtype> static inline int isMatrix(const iScalar<vtype> tmp) { return TensorIndexRecursion<Level-1>::isMatrix(tmp._internal); }
template<class vtype,int N> static inline int isMatrix(const iVector<vtype,N> tmp){ return TensorIndexRecursion<Level-1>::isMatrix(tmp._internal[0]); }
template<class vtype,int N> static inline int isMatrix(const iMatrix<vtype,N> tmp){ return TensorIndexRecursion<Level-1>::isMatrix(tmp._internal[0][0]); }
////////////////////////////////////////////////////
// Trace
////////////////////////////////////////////////////
template<class vtype>
static auto traceIndex(const iScalar<vtype> arg) -> iScalar<decltype(TensorIndexRecursion<Level-1>::traceIndex(arg._internal))>
{
@@ -215,6 +237,24 @@ class TensorIndexRecursion {
template<>
class TensorIndexRecursion<0> {
public:
////////////////////////////////////////////////////
// Type Queries
////////////////////////////////////////////////////
template<class vtype> static inline int indexRank(const iScalar<vtype> tmp) { return 1; }
template<class vtype,int N> static inline int indexRank(const iVector<vtype,N> tmp){ return N; }
template<class vtype,int N> static inline int indexRank(const iMatrix<vtype,N> tmp){ return N; }
template<class vtype> static inline int isScalar(const iScalar<vtype> tmp) { return true;}
template<class vtype,int N> static inline int isScalar(const iVector<vtype,N> tmp){ return false;}
template<class vtype,int N> static inline int isScalar(const iMatrix<vtype,N> tmp){ return false;}
template<class vtype> static inline int isVector(const iScalar<vtype> tmp) { return false;}
template<class vtype,int N> static inline int isVector(const iVector<vtype,N> tmp){ return true;}
template<class vtype,int N> static inline int isVector(const iMatrix<vtype,N> tmp){ return false;}
template<class vtype> static inline int isMatrix(const iScalar<vtype> tmp) { return false;}
template<class vtype,int N> static inline int isMatrix(const iVector<vtype,N> tmp){ return false;}
template<class vtype,int N> static inline int isMatrix(const iMatrix<vtype,N> tmp){ return true;}
/////////////////////////////////////////
// Ends recursion for trace (scalar/vector/matrix)
@@ -302,6 +342,26 @@ class TensorIndexRecursion<0> {
////////////////////////////////////////////////////////////////////////////////////////////////////////
// External wrappers
////////////////////////////////////////////////////////////////////////////////////////////////////////
template<int Level,class vtype> inline int indexRank(void)
{
vtype tmp;
return TensorIndexRecursion<Level>::indexRank(tmp);
}
template<int Level,class vtype> inline int isScalar(void)
{
vtype tmp;
return TensorIndexRecursion<Level>::isScalar(tmp);
}
template<int Level,class vtype> inline int isVector(void)
{
vtype tmp;
return TensorIndexRecursion<Level>::isVector(tmp);
}
template<int Level,class vtype> inline int isMatrix(void)
{
vtype tmp;
return TensorIndexRecursion<Level>::isMatrix(tmp);
}
template<int Level,class vtype> inline auto traceIndex (const vtype &arg) -> RemoveCRV(TensorIndexRecursion<Level>::traceIndex(arg))
{

View File

@@ -281,8 +281,8 @@ namespace Grid {
template<typename T>
class getPrecision{
public:
typedef typename getVectorType<T>::type vector_obj; //get the vector_obj (i.e. a grid Tensor) if its a Lattice<vobj>, do nothing otherwise (i.e. if fundamental or grid Tensor)
//get the vector_obj (i.e. a grid Tensor) if its a Lattice<vobj>, do nothing otherwise (i.e. if fundamental or grid Tensor)
typedef typename getVectorType<T>::type vector_obj;
typedef typename GridTypeMapper<vector_obj>::scalar_type scalar_type; //get the associated scalar type. Works on fundamental and tensor types
typedef typename GridTypeMapper<scalar_type>::Realified real_scalar_type; //remove any std::complex wrapper, should get us to the fundamental type