Answer by Dani for Determine neighboring cells in a two-dimensional grid with...
Based on Comevussor's answer, I've end up with this code:@nb.njit(nb.i8[:](nb.i8, nb.i8), fastmath=True)def celdas_vecinas(cell,n): Nt = n**2 # total number of cells x = cell % n; y = cell // n # x,y...
View ArticleAnswer by GolamMazid Sajib for Determine neighboring cells in a...
Try with this:grid = [[20, 21, 22, 23, 24],[15, 16, 17, 18, 19],[10, 11, 12, 13, 14],[5, 6, 7, 8, 9],[0, 1, 2, 3, 4]]def celdas_vecinas(cell,n): Row = [-1, -1, -1, 0, 0, 0, 1, 1, 1] Col = [-1, 0, 1,...
View ArticleAnswer by Comevussor for Determine neighboring cells in a two-dimensional...
The lines periodicity is not working like the columns periodicity. I think you should first get the 2 cells on each side and then move up and down. I have tried this and it seems to work : def...
View ArticleAnswer by FBruzzesi for Determine neighboring cells in a two-dimensional grid...
Numpy implementation can take advantage numpy.argwhere to retrieve value indeces, create the grid of indices with numpy.ix_, and finally apply numpy.narray.ravel method to flat the array::import numpy...
View ArticleDetermine neighboring cells in a two-dimensional grid with periodic conditions
Suppose we have the following two-dimensional network, whose cell indexes we label with integers:20 21 22 23 2415 16 17 18 1910 11 12 13 145 6 7 8 90 1 2 3 4What I want is a function that receives as...
View Article