mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-18 15:57:05 +01:00
Added rank_non_trivial
This commit is contained in:
@ -56,22 +56,31 @@ namespace Grid {
|
||||
template <typename T> struct grid_tensor_att {
|
||||
static constexpr unsigned int depth = 0; // How many levels of Grid Tensor there are
|
||||
static constexpr unsigned int rank = 0; // The rank of the grid tensor (i.e. how many indices used)
|
||||
static constexpr unsigned int rank_non_trivial = 0; // As per rank, but excludes those of dimension 1
|
||||
static constexpr unsigned int count = 1; // total number of elements (i.e. product of dimensions)
|
||||
typedef T scalar_type; // Type of the underlying scalar
|
||||
static constexpr size_t scalar_size = sizeof(T); // Size of the underlying scalar in bytes
|
||||
static constexpr size_t size = scalar_size * count; // total size of elements in bytes
|
||||
// e.g. iScalar<iVector<Complex,1>>
|
||||
// depth = 2
|
||||
// rank = 1
|
||||
// rank_non_trivial = 0
|
||||
// count = 1
|
||||
// e.g. iVector<iMatrix<Complex,3>,4>
|
||||
// depth = 2
|
||||
// rank = 3
|
||||
// size = 36
|
||||
// rank_non_trivial = 3
|
||||
// count = 36
|
||||
// e.g. iScalar<iVector<iMatrix<Complex,4>,3>>
|
||||
// depth = 3
|
||||
// rank = 3
|
||||
// size = 48
|
||||
// rank_non_trivial = 3
|
||||
// count = 48
|
||||
};
|
||||
template <typename T> struct grid_tensor_att<iScalar<T>> {
|
||||
static constexpr unsigned int depth = 1 + grid_tensor_att<T>::depth;
|
||||
static constexpr unsigned int rank = 0 + grid_tensor_att<T>::rank;
|
||||
static constexpr unsigned int rank_non_trivial = 0 + grid_tensor_att<T>::rank_non_trivial;
|
||||
static constexpr unsigned int count = 1 * grid_tensor_att<T>::count;
|
||||
typedef typename grid_tensor_att<T>::scalar_type scalar_type;
|
||||
static constexpr size_t scalar_size = grid_tensor_att<T>::scalar_size;
|
||||
@ -80,6 +89,7 @@ namespace Grid {
|
||||
template <typename T, int N> struct grid_tensor_att<iVector<T, N>> {
|
||||
static constexpr unsigned int depth = 1 + grid_tensor_att<T>::depth;
|
||||
static constexpr unsigned int rank = 1 + grid_tensor_att<T>::rank;
|
||||
static constexpr unsigned int rank_non_trivial = (N>1 ? 1 : 0) + grid_tensor_att<T>::rank_non_trivial;
|
||||
static constexpr unsigned int count = N * grid_tensor_att<T>::count;
|
||||
typedef typename grid_tensor_att<T>::scalar_type scalar_type;
|
||||
static constexpr size_t scalar_size = grid_tensor_att<T>::scalar_size;
|
||||
@ -88,6 +98,7 @@ namespace Grid {
|
||||
template <typename T, int N> struct grid_tensor_att<iMatrix<T, N>> {
|
||||
static constexpr unsigned int depth = 1 + grid_tensor_att<T>::depth;
|
||||
static constexpr unsigned int rank = 2 + grid_tensor_att<T>::rank;
|
||||
static constexpr unsigned int rank_non_trivial = (N>1 ? 2 : 0) + grid_tensor_att<T>::rank_non_trivial;
|
||||
static constexpr unsigned int count = N * N * grid_tensor_att<T>::count;
|
||||
typedef typename grid_tensor_att<T>::scalar_type scalar_type;
|
||||
static constexpr size_t scalar_size = grid_tensor_att<T>::scalar_size;
|
||||
|
Reference in New Issue
Block a user