Skip to content

Commit

Permalink
Replace reduce(hcat, ...) by stack(...) (#1159)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm authored Jan 14, 2025
1 parent 3b30a9f commit 5b34c17
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/transforms/smoothing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function _smooth(mesh, L, n, λ, μ; revert=false)
points = eachvertex(mesh)

# matrix with coordinates (nvertices x ndims)
X = reduce(hcat, to.(points)) |> transpose
X = stack(to, points, dims=1)

# choose between apply and revert mode
λ₁, λ₂ = revert ? (-μ, -λ) : (λ, μ)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ See <https://math.stackexchange.com/a/99317>.
function svdbasis(p::AbstractVector{<:Point})
checkdim(first(p), 3)
= lentype(eltype(p))
X = reduce(hcat, to.(p))
X = stack(to, p)
μ = sum(X, dims=2) / size(X, 2)
Z = X .- μ
U = usvd(Z).U
Expand Down
8 changes: 4 additions & 4 deletions test/partitioning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ end
# all points in p1 are below those in p2
pts1 = [centroid(p1, i) for i in 1:nelements(p1)]
pts2 = [centroid(p2, i) for i in 1:nelements(p2)]
X1 = reduce(hcat, to.(pts1))
X2 = reduce(hcat, to.(pts2))
X1 = stack(to, pts1)
X2 = stack(to, pts2)
M1 = maximum(X1, dims=2)
m2 = minimum(X2, dims=2)
@test all(X1[2, j] < m2[2] for j in 1:size(X1, 2))
Expand Down Expand Up @@ -185,8 +185,8 @@ end
# all points in p1 are to the left of p2
pts1 = [centroid(p1, i) for i in 1:nelements(p1)]
pts2 = [centroid(p2, i) for i in 1:nelements(p2)]
X1 = reduce(hcat, to.(pts1))
X2 = reduce(hcat, to.(pts2))
X1 = stack(to, pts1)
X2 = stack(to, pts2)
M1 = maximum(X1, dims=2)
m2 = minimum(X2, dims=2)
@test all(X1[1, j] < m2[1] for j in 1:size(X1, 2))
Expand Down

0 comments on commit 5b34c17

Please sign in to comment.