Skip to content

Commit

Permalink
Remove specialized methods (#47)
Browse files Browse the repository at this point in the history
* Remove specialized methods

* Fixes

* Fix
  • Loading branch information
blegat authored Jun 14, 2024
1 parent 8b26f89 commit 333eddf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 34 deletions.
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

0 comments on commit 333eddf

Please sign in to comment.