@@ -21,6 +21,24 @@ using BenchmarkTools
2121 @test test_constructors ()
2222end
2323
24+ # ################################################################
25+
26+ @testset " Updates" begin
27+ A= ExtendableSparseMatrix (10 ,10 )
28+ @test nnz (A)== 0
29+ A[1 ,3 ]= 5
30+ updateindex! (A,+ ,6.0 ,4 ,5 )
31+ updateindex! (A,+ ,0.0 ,2 ,3 )
32+ @test nnz (A)== 2
33+ rawupdateindex! (A,+ ,0.0 ,2 ,3 )
34+ @test nnz (A)== 3
35+ dropzeros! (A)
36+ @test nnz (A)== 2
37+ rawupdateindex! (A,+ ,0.1 ,2 ,3 )
38+ @test nnz (A)== 3
39+ dropzeros! (A)
40+ @test nnz (A)== 3
41+ end
2442# ################################################################
2543function test_timing (k,l,m)
2644 t1= @belapsed fdrand ($ k,$ l,$ m,matrixtype= $ SparseMatrixCSC) seconds= 1
171189 @test test_fdrand_coo (10 ,10 ,10 )
172190end
173191
192+
193+
194+ # #############################################
195+ function test_fdrand_update (k,l,m)
196+ A1= fdrand (k,l,m,rand= ()-> 1 ,matrixtype= ExtendableSparseMatrix,update = (A,v,i,j)-> A[i,j]+= v)
197+ A2= fdrand (k,l,m,rand= ()-> 1 ,matrixtype= ExtendableSparseMatrix,update = (A,v,i,j)-> rawupdateindex! (A,+ ,v,i,j))
198+ A3= fdrand (k,l,m,rand= ()-> 1 ,matrixtype= ExtendableSparseMatrix,update = (A,v,i,j)-> updateindex! (A,+ ,v,i,j))
199+
200+ A1≈ A2 && A1 ≈ A3
201+ end
202+
203+ @testset " fdrand_update" begin
204+ @test test_fdrand_update (1000 ,1 ,1 )
205+ @test test_fdrand_update (20 ,20 ,1 )
206+ @test test_fdrand_update (10 ,10 ,10 )
207+ end
208+
209+
210+
211+
174212# #############################################
175213
176214function test_precon (Precon,k,l,m;maxiter= 10000 )
236274 @test test_hermitian (300 ,:U )
237275 @test test_hermitian (300 ,:L )
238276end
277+
278+
279+
0 commit comments