#ifndef GRID_LEXICOGRAPHIC_H #define GRID_LEXICOGRAPHIC_H namespace Grid{ class Lexicographic { public: static inline void CoorFromIndex (std::vector& coor,int index,const std::vector &dims){ int nd= dims.size(); coor.resize(nd); for(int d=0;d& coor,int &index,const std::vector &dims){ int nd=dims.size(); if(nd > coor.size()) { std::cout<< "coor.size "<dims.size "<& coor,int &index,const std::vector &dims){ int nd=dims.size(); int stride=1; index=0; for(int d=nd-1;d>=0;d--){ index = index+stride*coor[d]; stride=stride*dims[d]; } } static inline void CoorFromIndexReversed (std::vector& coor,int index,const std::vector &dims){ int nd= dims.size(); coor.resize(nd); for(int d=nd-1;d>=0;d--){ coor[d] = index % dims[d]; index = index / dims[d]; } } }; } #endif