Skip to content

Commit

Permalink
Use Julia's native SVD pinv
Browse files Browse the repository at this point in the history
  • Loading branch information
lukem12345 committed May 23, 2024
1 parent 516cb66 commit 3d0f648
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/DiscreteExteriorCalculus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,10 @@ function ♯_mat(s::AbstractDeltaDualComplex2D, ::LLSDDSharp)
# TODO: Move around ' as appropriate to minimize transposing.
X = stack(de_vecs)'
# See: https://arxiv.org/abs/1102.1845
QRX = qr(X, ColumnNorm())
LLS = (pinv(QRX.R) * QRX.Q')[QRX.p,:]
#QRX = qr(X, ColumnNorm())
#LLS = (inv(QRX.R) * QRX.Q')[QRX.p,:]
#LLS = pinv(X'*(X))*(X')
LLS = pinv(X)
for (i,e) in enumerate(tri_edges)
♯_m[t, e] = LLS[:,i]'*weights[i]
end
Expand Down
2 changes: 1 addition & 1 deletion test/DiscreteExteriorCalculus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ for (primal_s,s) in flat_meshes
# Note that we check explicitly both cases of signedness, because orient!
# picks in/outside without regard to the embedding.
# This is the "right/left-hand-rule trick."
@test all(isapprox.(only.(♭_♯_m * X♭), eval_constant_primal_form(s, X♯), atol=1e-14)) ||
@test all(isapprox.(only.(♭_♯_m * X♭), eval_constant_primal_form(s, X♯), atol=1e-13)) ||
all(isapprox.(only.(♭_♯_m * X♭), -eval_constant_primal_form(s, X♯), atol=1e-13))

# This test shows how the musical isomorphism chaining lets you further
Expand Down

0 comments on commit 3d0f648

Please sign in to comment.