From 16a88c66df9d38a614fe3898e45acb24fdbab01d Mon Sep 17 00:00:00 2001 From: GeorgeR227 <78235421+GeorgeR227@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:54:36 -0400 Subject: [PATCH 1/2] Remove intermediate arrays Done in dec_p_derivbound --- src/FastDEC.jl | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/FastDEC.jl b/src/FastDEC.jl index 833cb00d..9dc43cf7 100644 --- a/src/FastDEC.jl +++ b/src/FastDEC.jl @@ -15,6 +15,7 @@ using ACSets.DenseACSets: attrtype_type using Catlab, Catlab.CategoricalAlgebra.CSets using ..SimplicialSets, ..DiscreteExteriorCalculus import ..DiscreteExteriorCalculus: ∧ +import ..SimplicialSets: numeric_sign export dec_boundary, dec_differential, dec_dual_derivative, dec_hodge_star, dec_inv_hodge_star, dec_wedge_product, dec_c_wedge_product, dec_p_wedge_product, dec_c_wedge_product!, dec_wedge_product_pd, dec_wedge_product_dp, ∧, @@ -399,11 +400,6 @@ function dec_p_derivbound(::Type{Val{0}}, sd::HasDeltaSet; transpose::Bool=false V = Vector{Int8}(undef, vec_size) - e_orient::Vector{Int8} = sd[:edge_orientation] - for i in eachindex(e_orient) - e_orient[i] = (e_orient[i] == 1 ? 1 : -1) - end - for i in edges(sd) j = 2 * i - 1 @@ -413,7 +409,7 @@ function dec_p_derivbound(::Type{Val{0}}, sd::HasDeltaSet; transpose::Bool=false J[j] = sd[i, :∂v0] J[j+1] = sd[i, :∂v1] - sign_term = e_orient[i] + sign_term = numeric_sign(sd[i, :edge_orientation]) V[j] = sign_term V[j+1] = -1 * sign_term @@ -439,13 +435,6 @@ function dec_p_derivbound(::Type{Val{1}}, sd::HasDeltaSet; transpose::Bool=false V = Vector{Int8}(undef, vec_size) - tri_sign_list::Vector{Int8} = sign(2, sd) - - e_orient::Vector{Int8} = sd[:edge_orientation] - for i in eachindex(e_orient) - e_orient[i] = (e_orient[i] == 1 ? 1 : -1) - end - for i in triangles(sd) j = 3 * i - 2 @@ -453,15 +442,15 @@ function dec_p_derivbound(::Type{Val{1}}, sd::HasDeltaSet; transpose::Bool=false I[j+1] = i I[j+2] = i - tri_sign = tri_sign_list[i] + tri_sign = numeric_sign(sd[i, :tri_orientation]) J[j] = sd[i, :∂e0] J[j+1] = sd[i, :∂e1] J[j+2] = sd[i, :∂e2] - edge_sign_0 = e_orient[sd[i, :∂e0]] - edge_sign_1 = e_orient[sd[i, :∂e1]] - edge_sign_2 = e_orient[sd[i, :∂e2]] + edge_sign_0 = numeric_sign(sd[sd[i, :∂e0], :edge_orientation]) + edge_sign_1 = numeric_sign(sd[sd[i, :∂e1], :edge_orientation]) + edge_sign_2 = numeric_sign(sd[sd[i, :∂e2], :edge_orientation]) V[j] = edge_sign_0 * tri_sign V[j+1] = -1 * edge_sign_1 * tri_sign From 1cc7dde3b4afd1aa1324aa054b1913a96d689871 Mon Sep 17 00:00:00 2001 From: GeorgeR227 <78235421+GeorgeR227@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:07:30 -0400 Subject: [PATCH 2/2] Type assert bools --- src/FastDEC.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/FastDEC.jl b/src/FastDEC.jl index 9dc43cf7..58eb734a 100644 --- a/src/FastDEC.jl +++ b/src/FastDEC.jl @@ -409,7 +409,7 @@ function dec_p_derivbound(::Type{Val{0}}, sd::HasDeltaSet; transpose::Bool=false J[j] = sd[i, :∂v0] J[j+1] = sd[i, :∂v1] - sign_term = numeric_sign(sd[i, :edge_orientation]) + sign_term = numeric_sign(sd[i, :edge_orientation]::Bool) V[j] = sign_term V[j+1] = -1 * sign_term @@ -442,15 +442,15 @@ function dec_p_derivbound(::Type{Val{1}}, sd::HasDeltaSet; transpose::Bool=false I[j+1] = i I[j+2] = i - tri_sign = numeric_sign(sd[i, :tri_orientation]) + tri_sign = numeric_sign(sd[i, :tri_orientation]::Bool) J[j] = sd[i, :∂e0] J[j+1] = sd[i, :∂e1] J[j+2] = sd[i, :∂e2] - edge_sign_0 = numeric_sign(sd[sd[i, :∂e0], :edge_orientation]) - edge_sign_1 = numeric_sign(sd[sd[i, :∂e1], :edge_orientation]) - edge_sign_2 = numeric_sign(sd[sd[i, :∂e2], :edge_orientation]) + edge_sign_0 = numeric_sign(sd[sd[i, :∂e0], :edge_orientation]::Bool) + edge_sign_1 = numeric_sign(sd[sd[i, :∂e1], :edge_orientation]::Bool) + edge_sign_2 = numeric_sign(sd[sd[i, :∂e2], :edge_orientation]::Bool) V[j] = edge_sign_0 * tri_sign V[j+1] = -1 * edge_sign_1 * tri_sign