Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:13

0001 // name=GridSpecTest.cc ; gcc $name -std=c++11 -lstdc++  -o /tmp/$name && /tmp/$name
0002 #include <array>
0003 #include <iostream>
0004 #include <sstream>
0005 #include <vector>
0006 #include <string>
0007 #include <cassert>
0008 
0009 void parse_gridspec(std::array<int,9>& grid, const char* spec)
0010 {
0011     int idx = 0 ; 
0012     std::stringstream ss(spec); 
0013     std::string s;
0014     while (std::getline(ss, s, ',')) 
0015     {
0016         std::stringstream tt(s); 
0017         std::string t;
0018         while (std::getline(tt, t, ':')) grid[idx++] = std::atoi(t.c_str()) ; 
0019     }
0020     for(int i=0 ; i < 9 ; i++) std::cout << grid[i] << " " ; 
0021     std::cout << std::endl ;           
0022 }
0023 
0024 int main(int argc, char** argv)
0025 {
0026     const char* spec = "-10:11:2,-10:11:2,-10:11:2" ; 
0027     std::array<int,9> grid ; 
0028     parse_gridspec(grid, spec); 
0029 
0030     for(int i=grid[0] ; i < grid[1] ; i+=grid[2] )
0031     for(int j=grid[3] ; j < grid[4] ; j+=grid[5] )
0032     for(int k=grid[6] ; k < grid[7] ; k+=grid[8] )
0033     {
0034         std::cout << "(" << i << "," << j << "," << k << ")" << std::endl ; 
0035     }
0036 
0037 
0038     return 0 ; 
0039 }