Vectorized creation of Grid Matrix