You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
macro sparsearray(size, rule)
return quote
_A = spzeros($size...)
$(push!(rule.args, :(_ => 0)))
for _itr in eachindex(_A)
_A[_itr] = @match(_itr.I, $rule)
end
_A
end
end
an example is
@sparsearray (5,5) begin
(n,m), if n==m+1 end => m
(n,m), if n==m-1 end => n+10
(1,5) => 1
end
I've realized that Match.jl is perfect for creating in julia an equivalent of SparseArray
https://reference.wolfram.com/language/ref/SparseArray.html
which I find quite useful in Mathematica.
my basic implementation is this
an example is
which creates the matrix
0.0 11.0 0.0 0.0 1.0
1.0 0.0 12.0 0.0 0.0
0.0 2.0 0.0 13.0 0.0
0.0 0.0 3.0 0.0 14.0
0.0 0.0 0.0 4.0 0.0
perhaps other people may find this application interesting, so it would be nice to include an example like this in the documentation
The text was updated successfully, but these errors were encountered: