Hi,
I feel that my problem must be shared by some of you.
I need to build the sparse matrix associated to a 2d Finite Element method. Following the advice of Viral, I built 3 lists I,J,values containing the indices of nonzeros elements. So each element of I or J contains the linear index associated to a tuple (i,j) because my problem is 2d. However, this is very inconvenient.
Basically, I need to add values to a sparse matrix and this is slow.
Hence, I am looking for a convenient way to build the indices I,J,V so that I can call sparse(I,J,V) in the end.
By convenient way, I mean that I want to operations +,-,*,... to be defined somehow.
For example, would it be possible to have a sparse matrix defined as
struct spmat
I::Int64[]
J::Int64[]
val::Float64[]
end
and the plus operation would just push to I,J,val. Am I re-inventing the wheel?
Thank you for your suggestions.