def getindex(ndim, ind, strides):
 ret = 0
 for i in range(ndim):
  ret += (strides[i] * ind[i])
 return ret

def getindex ( ndim , ind , strides ) : ret = 0 for i in range ( ndim ) : ret += ( strides [ i ] * ind [ i ] ) return ret
convert multi-dimensional index to the position in the flat list .