mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-19 00:07:05 +01:00
Coordinate handling GPU ready avoid malloc
This commit is contained in:
@ -7,7 +7,8 @@ namespace Grid{
|
||||
class Lexicographic {
|
||||
public:
|
||||
|
||||
static inline void CoorFromIndex (std::vector<int>& coor,int index,const std::vector<int> &dims){
|
||||
template<class coor_t>
|
||||
static inline void CoorFromIndex (coor_t& coor,int index,const coor_t &dims){
|
||||
int nd= dims.size();
|
||||
coor.resize(nd);
|
||||
for(int d=0;d<nd;d++){
|
||||
@ -16,7 +17,8 @@ namespace Grid{
|
||||
}
|
||||
}
|
||||
|
||||
static inline void IndexFromCoor (const std::vector<int>& coor,int &index,const std::vector<int> &dims){
|
||||
template<class coor_t>
|
||||
static inline void IndexFromCoor (const coor_t& coor,int &index,const coor_t &dims){
|
||||
int nd=dims.size();
|
||||
int stride=1;
|
||||
index=0;
|
||||
@ -26,7 +28,8 @@ namespace Grid{
|
||||
}
|
||||
}
|
||||
|
||||
static inline void IndexFromCoorReversed (const std::vector<int>& coor,int &index,const std::vector<int> &dims){
|
||||
template<class coor_t>
|
||||
static inline void IndexFromCoorReversed (const coor_t& coor,int &index,const coor_t &dims){
|
||||
int nd=dims.size();
|
||||
int stride=1;
|
||||
index=0;
|
||||
@ -35,7 +38,8 @@ namespace Grid{
|
||||
stride=stride*dims[d];
|
||||
}
|
||||
}
|
||||
static inline void CoorFromIndexReversed (std::vector<int>& coor,int index,const std::vector<int> &dims){
|
||||
template<class coor_t>
|
||||
static inline void CoorFromIndexReversed (coor_t& coor,int index,const coor_t &dims){
|
||||
int nd= dims.size();
|
||||
coor.resize(nd);
|
||||
for(int d=nd-1;d>=0;d--){
|
||||
|
Reference in New Issue
Block a user