Question: Add duplicates in sparse Matrices


I have a small Finite Element program in Maple. I want to accelerate the Matrix assembly. For Matlab this works like described here ( under "Triplet Sparse Storage". There, two indexing Vectors are used to place the values into a sparse Matrix with the Matlab function sparse. If index pairs are duplicate, they are added.


Now I want to ask if this is also possible in Maple? Is there a similar command for Maple like the Matlab sparse? Or is there some other way to do this?

I can show my problem on a small example:

s := {(1, 1) = 3, (2, 2) = 2, (2, 2) = 7}; Matrix(2, 2, s)

returns the Matrix [[3, 0], [0, 7]]. But I would want to add the two entries of (2,2) instead of replacing them, so that it would return [[3, 0], [0, 9]]. Does anyone have an idea?

Best regards

Please Wait...