Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove specialized methods #47

Merged
merged 3 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,8 @@ function unsafe_push!(a::SparseArrays.SparseVector, k, v)
a[k] = MA.add!!(a[k], v)
return a
end

function unsafe_push!(a::Vector, k, v)
a[k] = MA.add!!(a[k], v)
return a
end
34 changes: 0 additions & 34 deletions src/mtables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,6 @@ end
_key(_, k) = k
_key(mstr::MTable, k) = mstr[k]

function MA.operate!(
ms::UnsafeAddMul{<:MTable},
res::AbstractCoefficients,
v::AbstractCoefficients,
w::AbstractCoefficients,
)
for (kv, a) in nonzero_pairs(v)
for (kw, b) in nonzero_pairs(w)
c = ms.structure(kv, kw)
for (k, v) in nonzero_pairs(c)
res[ms.structure[k]] += v * a * b
end
end
end
return res
end

function MA.operate!(
ms::UnsafeAddMul{<:MTable},
res::AbstractSparseVector,
Expand All @@ -138,20 +121,3 @@ function MA.operate!(
res .+= sparsevec(idcs, vals, length(res))
return res
end

function MA.operate!(
ms::UnsafeAddMul{<:MTable},
res::AbstractVector,
v::AbstractVector,
w::AbstractVector,
)
for (kv, a) in nonzero_pairs(v)
for (kw, b) in nonzero_pairs(w)
c = ms.structure(kv, kw)
for (k, v) in nonzero_pairs(c)
res[ms.structure[k]] += v * a * b
end
end
end
return res
end
4 changes: 4 additions & 0 deletions test/test_example_acoeffs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ end
# the default arithmetic implementation uses this access
Base.getindex(ac::ACoeffs, idx) = ac.vals[idx]
Base.setindex!(ac::ACoeffs, val, idx) = ac.vals[idx] = val
function SA.unsafe_push!(ac::ACoeffs, idx, val)
ac.vals[idx] = MA.add!!(ac.vals[idx], val)
return ac
end
Loading