@@ -22,17 +22,19 @@ using BlockSparseArrays:
2222 BlockSparseMatrix,
2323 BlockSparseVector,
2424 BlockView,
25+ blockdiagindices,
2526 blockreshape,
2627 blockstoredlength,
2728 blockstype,
2829 blocktype,
2930 eachblockstoredindex,
3031 eachstoredblock,
32+ eachstoredblockdiagindex,
3133 sparsemortar,
3234 view!
3335using GPUArraysCore: @allowscalar
3436using JLArrays: JLArray, JLMatrix
35- using LinearAlgebra: Adjoint, Transpose, dot, norm
37+ using LinearAlgebra: Adjoint, Transpose, dot, norm, tr
3638using SparseArraysBase: SparseArrayDOK, SparseMatrixDOK, SparseVectorDOK, storedlength
3739using Test: @test , @test_broken , @test_throws , @testset , @inferred
3840using TestExtras: @constinferred
@@ -217,10 +219,26 @@ arrayts = (Array, JLArray)
217219 a[Block (1 , 2 )] = randn (elt, 2 , 3 )
218220 @test issetequal (eachstoredblock (a), [a[Block (2 , 1 )], a[Block (1 , 2 )]])
219221 @test issetequal (eachblockstoredindex (a), [Block (2 , 1 ), Block (1 , 2 )])
222+ @test issetequal (blockdiagindices (a), [Block (1 , 1 ), Block (2 , 2 )])
223+ @test isempty (eachstoredblockdiagindex (a))
224+ @test norm (a) ≈ norm (Array (a))
225+ for p in 1 : 3
226+ @test norm (a, p) ≈ norm (Array (a), p)
227+ end
228+ @test tr (a) ≈ tr (Array (a))
220229
221230 a[3 , 3 ] = NaN
222231 @test isnan (norm (a))
223232
233+ a = dev (BlockSparseArray {elt} (undef, [2 , 3 ], [2 , 3 ]))
234+ a[Block (1 , 1 )] = dev (randn (elt, 2 , 2 ))
235+ @test issetequal (eachstoredblockdiagindex (a), [Block (1 , 1 )])
236+ @test norm (a) ≈ norm (Array (a))
237+ for p in 1 : 3
238+ @test norm (a, p) ≈ norm (Array (a), p)
239+ end
240+ @test tr (a) ≈ tr (Array (a))
241+
224242 # Empty constructor
225243 for a in (dev (BlockSparseArray {elt} (undef)),)
226244 @test size (a) == ()
0 commit comments