mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-25 13:15:55 +01:00
Query tensor structures
This commit is contained in:
parent
46879e1658
commit
b96daf53a0
@ -47,6 +47,28 @@ template<int Level>
|
|||||||
class TensorIndexRecursion {
|
class TensorIndexRecursion {
|
||||||
|
|
||||||
public:
|
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>
|
template<class vtype>
|
||||||
static auto traceIndex(const iScalar<vtype> arg) -> iScalar<decltype(TensorIndexRecursion<Level-1>::traceIndex(arg._internal))>
|
static auto traceIndex(const iScalar<vtype> arg) -> iScalar<decltype(TensorIndexRecursion<Level-1>::traceIndex(arg._internal))>
|
||||||
{
|
{
|
||||||
@ -215,6 +237,24 @@ class TensorIndexRecursion {
|
|||||||
template<>
|
template<>
|
||||||
class TensorIndexRecursion<0> {
|
class TensorIndexRecursion<0> {
|
||||||
public:
|
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)
|
// Ends recursion for trace (scalar/vector/matrix)
|
||||||
@ -302,6 +342,26 @@ class TensorIndexRecursion<0> {
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// External wrappers
|
// 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))
|
template<int Level,class vtype> inline auto traceIndex (const vtype &arg) -> RemoveCRV(TensorIndexRecursion<Level>::traceIndex(arg))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user