3 neigh::neigh(const int& dimension, const int& length)
5 nfield = new int[ipow(dimension,length)*2*dimension];
7 for (int ipos = 0; ipos < ipow(length,dimension); ipos++)
9 for (int idir = 0; idir < 2*dimension; idir++)
11 if ( idir < dimension ) //pos direction
13 if ( ( ipos/ipow(length,idir%dimension) ) % length == length-1 )
14 nfield[ipos*2*dimension + idir] = ipos - ipow(length,idir%dimension)*(length-1);
16 nfield[ipos*2*dimension + idir] = ipos + ipow(length,idir%dimension);
20 if ( ( ipos/ipow(length,idir%dimension) ) % length == 0 )
21 nfield[ipos*2*dimension + idir] = ipos + ipow(length,idir%dimension)*(length-1);
23 nfield[ipos*2*dimension + idir] = ipos - ipow(length,idir%dimension);