@@ -187,7 +187,7 @@ function ggrid(Nx::Int, Ny::Int, connect::Symbol = :c4)
187187 # MATLAB:
188188 # xy = [(1:N)', repmat((1:Ny)',Nx,1)];
189189 # xy(:,1) = ceil(xy(:,1)/Ny);
190- xy = hcat ( ceil ( (1 : N) / Ny), repmat (1 : Ny, Nx) )
190+ xy = hcat ( ceil .( collect (1 : N) / Ny), repeat (1 : Ny, Nx) )
191191
192192 if connect == :c4 # this is the default, i.e., l; r; u; d.
193193 # make 1-D weight matrices
@@ -198,7 +198,8 @@ function ggrid(Nx::Int, Ny::Int, connect::Symbol = :c4)
198198 Wy = spdiagm (- 1 => ey, 1 => ey)
199199 # Wy = spdiagm((ey, ey), (-1, 1))
200200 # form the 2-D weight matrix
201- W = kron (speye (Nx), Wy) + kron (Wx, speye (Ny)) # this keeps a sparse form
201+ W = kron (sparse (1.0 I, Nx, Nx), Wy) + kron (Wx, sparse (1.0 I, Ny, Ny))
202+ # this keeps a sparse form
202203 else # now for 8-connected or fully-connected cases
203204 W = sparse (pairwise (Euclidean (), xy' )) # This is from Distances package.
204205 W[1 : (N + 1 ): (N * N)] = 10 # set each diagonal entry to 10 to prevent blowup.
0 commit comments