@@ -34,6 +34,8 @@ julia> Pkg.add("SparseArraysBase")
3434```` julia
3535using SparseArraysBase:
3636 SparseArrayDOK,
37+ SparseMatrixDOK,
38+ SparseVectorDOK,
3739 eachstoredindex,
3840 getstoredindex,
3941 getunstoredindex,
@@ -62,15 +64,16 @@ a[1, 2] = 12
6264SparseArraysBase interface:
6365
6466```` julia
67+ using Dictionaries: IndexError
6568@test issetequal (eachstoredindex (a), [CartesianIndex (1 , 2 )])
6669@test getstoredindex (a, 1 , 2 ) == 12
67- @test_throws KeyError getstoredindex (a, 1 , 1 )
70+ @test_throws IndexError getstoredindex (a, 1 , 1 )
6871@test getunstoredindex (a, 1 , 1 ) == 0
6972@test getunstoredindex (a, 1 , 2 ) == 0
7073@test ! isstored (a, 1 , 1 )
7174@test isstored (a, 1 , 2 )
7275@test setstoredindex! (copy (a), 21 , 1 , 2 ) == [0 21 ; 0 0 ]
73- @test_throws KeyError setstoredindex! (copy (a), 21 , 2 , 1 )
76+ @test_throws IndexError setstoredindex! (copy (a), 21 , 2 , 1 )
7477@test setunstoredindex! (copy (a), 21 , 1 , 2 ) == [0 21 ; 0 0 ]
7578@test storedlength (a) == 1
7679@test issetequal (storedpairs (a), [CartesianIndex (1 , 2 ) => 12 ])
@@ -81,11 +84,30 @@ AbstractArray functionality:
8184
8285```` julia
8386b = a .+ 2 .* a'
87+ @test b isa SparseMatrixDOK{Float64}
8488@test b == [0 12 ; 24 0 ]
8589@test storedlength (b) == 2
86- @test b isa SparseArrayDOK{Float64}
8790
88- a * a'
91+ b = permutedims (a, (2 , 1 ))
92+ @test b isa SparseMatrixDOK{Float64}
93+ @test b[1 , 1 ] == a[1 , 1 ]
94+ @test b[2 , 1 ] == a[1 , 2 ]
95+ @test b[1 , 2 ] == a[2 , 1 ]
96+ @test b[2 , 2 ] == a[2 , 2 ]
97+
98+ b = a * a'
99+ @test b isa SparseMatrixDOK{Float64}
100+ @test b == [144 0 ; 0 0 ]
101+ @test storedlength (b) == 1
102+ ````
103+
104+ Second column.
105+
106+ ```` julia
107+ b = a[1 : 2 , 2 ]
108+ @test b isa SparseVectorDOK{Float64}
109+ @test b == [12 , 0 ]
110+ @test storedlength (b) == 1
89111````
90112
91113---
0 commit comments