@@ -24,6 +24,17 @@ using .Main.SizedArrays
2424const n= 12 # Size of matrix problem to test
2525Random. seed! (1 )
2626
27+ # wrapper to avoid dispatching to diagonal methods
28+ struct NotDiagonal{T,A<: AbstractMatrix{T} } <: AbstractMatrix{T}
29+ a :: A
30+ end
31+ Base. size (N:: NotDiagonal ) = size (N. a)
32+ Base. getindex (N:: NotDiagonal , i:: Int , j:: Int ) = N. a[i, j]
33+ LinearAlgebra. isdiag (N:: NotDiagonal ) = false # this contradicts `getindex`
34+ LinearAlgebra. ishermitian (N:: NotDiagonal ) = ishermitian (N. a)
35+ LinearAlgebra. istriu (N:: NotDiagonal ) = istriu (N. a)
36+ LinearAlgebra. istril (N:: NotDiagonal ) = istril (N. a)
37+
2738@testset for relty in (Float32, Float64, BigFloat), elty in (relty, Complex{relty})
2839 dd= convert (Vector{elty}, randn (n))
2940 vv= convert (Vector{elty}, randn (n))
@@ -37,8 +48,9 @@ Random.seed!(1)
3748 M = Matrix (D)
3849 # we can't directly compare with a Matrix, since the dense methods often dispatch
3950 # to Diagonal ones. We therefore compare with other structured matrix types
40- # which have their own implementations
41- DM = elty <: Real ? Hermitian (M) : UpperTriangular (M)
51+ # which have their own implementations.
52+ # We wrap the complex matrices in NotDiagonal to avoid falling back to Diagonal methods
53+ DM = elty <: Real ? Hermitian (M) : NotDiagonal (UpperTriangular (M))
4254
4355 @testset " constructor" begin
4456 for x in (dd, GenericArray (dd))
0 commit comments