4#include "Grid/comb.hpp"
5#include "Grid/grid_key_expression.hpp"
6#include "Space/Shape/Point.hpp"
17template<
unsigned int dim,
typename index_type>
27 template<
typename exp1>
30 for (
size_t i = 0 ; i < dim ; i++)
31 this->
k[i] = exp.value(i);
43 __device__ __host__
inline grid_key_dx(std::initializer_list<long int> p1)
72 for (
size_t i = 0 ; i < dim ; i++)
83 for (
size_t i = 0 ; i < dim ; i++)
94 for (
size_t i = 0 ; i < dim ; i++)
105 for (
size_t i = 0 ; i < dim ; i++)
116 for (
size_t i = 0 ; i < dim ; i++)
127 for (
size_t i = 0 ; i < dim ; i++)
138 for (
size_t i = 0 ; i < dim ; i++)
148 template<
typename ...T> __device__ __host__
inline grid_key_dx(
const size_t v,
const T...t)
150#if defined(SE_CLASS1) && !defined(__NVCC__)
151 if (
sizeof...(t) != dim -1)
152 {std::cerr <<
"Error grid_key: " << __FILE__ <<
" " << __LINE__ <<
" creating a key of dimension " << dim <<
" require " << dim <<
" numbers " <<
sizeof...(t) + 1 <<
" provided" <<
"\n";}
172 for (
size_t i = 0 ; i < dim ; i++)
181 for (
size_t i = 0 ; i < dim ; i++)
190 for (
size_t i = 0 ; i < dim ; i++)
201 for (
size_t i = 0 ; i < dim ; i++)
220 for (
size_t i = 0 ; i < dim ; i++)
236 for (
size_t i = 0 ; i < dim ; i++)
312 template <
typename T>
336 for (
size_t i = 0 ; i < dim ; i++)
338 if (
k[i] != key_t.
k[i])
372 for (
long int i = dim-1 ; i >= 0; --i)
374 if (
k[i] < key_t.
k[i])
378 else if (
k[i] > key_t.
k[i])
388 static bool noPointers()
399 template<
typename a,
typename ...T>
400 __device__ __host__
inline void set(a v, T...t)
403 if (
sizeof...(t) != dim -1)
404 std::cerr <<
"Error grid_key: " << __FILE__ <<
" " << __LINE__ <<
"setting a key of dimension " << dim <<
" require " << dim <<
" numbers " <<
sizeof...(t) + 1 <<
" provided" << std::endl;
415 const long int(&
get_k()
const)[dim]
431 for (
size_t i = 0; i < dim ; i++)
456 template<
typename typeT =
size_t>
461 for (
size_t i = 0; i < dim ; i++)
477 __device__ __host__
inline mem_id
value(
size_t i)
const
490 __device__ __host__ index_type
operator[](index_type i)
const
503 __device__ __host__ index_type
get(index_type i)
const
516 __device__ __host__
void set_d(index_type i, index_type
id)
518#if defined(SE_CLASS1) && !defined(__NVCC__)
521 std::cerr <<
"grid_key_dx error: " << __FILE__ <<
" " << __LINE__ <<
" try to access dimension " << i <<
" on a grid_key_dx of size " << dim <<
"\n";
540 template<
typename a,
typename ...T> __device__ __host__
void invert_assign(a v,T...t)
551 template<
typename a,
typename ...T> __device__ __host__
void invert_assign(a v)
573template<
unsigned int dim,
unsigned int p>
579 template<
typename a,
typename ...T>
grid_key_d(a v,T...t)
585 template<
typename a,
typename ...T>
void invert_assign(a v,T...t)
591 template<
typename a,
typename ...T>
void invert_assign(a v)
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
std::string toString() const
Return the string with the point coordinate.
grid_key_d is the key to access any element in the grid
Expression template for grid_key_dx.
Main class that encapsulate a sub expression.
Main class that encapsulate a sum expression.
grid_key_dx is the key to access any element in the grid
__device__ __host__ grid_key_dx(const short(&k)[dim])
Constructor from buffer reference.
__device__ __host__ grid_key_dx(const unsigned short(&k)[dim])
Constructor from buffer reference.
__device__ __host__ grid_key_dx_sum< dim, grid_key_dx< dim >, Point< dim, long int > > operator+(const Point< dim, long int > &p) const
sum a point to the grid_key
__device__ __host__ grid_key_dx_sub< dim, grid_key_dx< dim, index_type >, grid_key_dx_expression< dim, T > > operator-(const grid_key_dx_expression< dim, T > &cmb) const
sum this key to another grid expression
__device__ __host__ grid_key_dx(const int(&k)[dim])
Constructor from buffer reference.
__device__ __host__ grid_key_dx< dim, index_type > & operator+=(const grid_key_dx< dim, index_type > &p)
sum a grid_key
bool operator==(const grid_key_dx< dim_t, index_type > &key_t) const
Check if two key are the same.
__device__ __host__ grid_key_dx()
Constructor.
bool operator<(const grid_key_dx< dim, index_type > &key_t) const
Check order of two keys.
void zero()
Set to zero the key.
__device__ __host__ void invert_assign()
Constructor.
__device__ __host__ grid_key_dx_sum< dim, grid_key_dx< dim >, comb< dim > > operator+(const comb< dim > &cmb) const
sum an a combination to the grid_key
Point< dim, long int > toPointS() const
Convert to a point the grid_key_dx.
__device__ __host__ grid_key_dx(const unsigned int(&k)[dim])
Constructor from buffer reference.
__device__ __host__ grid_key_dx_sub< dim, grid_key_dx< dim, index_type >, grid_key_dx< dim, index_type > > operator-(const grid_key_dx< dim, index_type > &cmb) const
sum an a combination to the grid_key
__device__ __host__ mem_id value(size_t i) const
Get the i index.
void one()
Set to one the key.
bool operator!=(const grid_key_dx< dim_t, index_type > &key_t)
Check if two key are the same.
__device__ __host__ grid_key_dx(const grid_key_dx_expression< dim, exp1 > &exp)
Constructor from expression.
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
__device__ __host__ grid_key_dx< dim, index_type > & operator-=(const grid_key_dx< dim, index_type > &p)
sum a grid_key
__device__ __host__ grid_key_dx(const size_t v, const T...t)
Construct a grid key from a list of numbers.
__device__ __host__ void invert_assign(a v, T...t)
Recursively invert the assignment.
__device__ __host__ grid_key_dx_sum< dim, grid_key_dx< dim, index_type >, grid_key_dx< dim, index_type > > operator+(const grid_key_dx< dim, index_type > &p) const
sum a grid_key to the grid_key
__device__ __host__ void invert_assign(a v)
assignment
__device__ __host__ grid_key_dx(const long int(&k)[dim])
Constructor from buffer reference.
bool isValid()
Check if the key is invalid (all components set to -1)
__device__ __host__ grid_key_dx(const size_t(&k)[dim])
Constructor from buffer reference.
__device__ __host__ grid_key_dx(std::initializer_list< long int > p1)
Constructor from initializer list.
void invalid()
Set to invalid the key.
std::string to_string() const
convert the information into a string
__host__ __device__ Point< dim, typeT > toPoint() const
Convert to a point the grid_key_dx.
index_type k[dim]
structure that store all the index
grid_key_dx(const comb< dim > &cmb)
Construct a grid key from a list of numbers.
__device__ __host__ grid_key_dx(const grid_key_dx< dim, index_type > &key)
Constructor from an other key.
__device__ __host__ index_type operator[](index_type i) const
Get the i index.
__device__ __host__ void set(a v, T...t)
set the Key from a list of numbers
const long int(& get_k() const)[dim]
Return the internal k structure.
__device__ __host__ index_type get(index_type i) const
Get the i index.
Position of the element of dimension d in the hyper-cube of dimension dim.