Skip to content

Commit 1d99f9f

Browse files
committed
Call symmetry check function instead of checking type
1 parent c57b0d7 commit 1d99f9f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/symmetric.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ issymmetric(A::Hermitian{<:Real}) = true
441441
issymmetric(A::Hermitian{<:Complex}) = isreal(A)
442442
issymmetric(A::Symmetric) = true
443443

444+
# check if the symmetry is known from the type
445+
_issymmetric(::Union{Symmetric, Hermitian{<:Real}}) = true
446+
_issymmetric(::Any) = false
447+
444448
adjoint(A::Hermitian) = A
445449
transpose(A::Symmetric) = A
446450
adjoint(A::Symmetric{<:Real}) = A

src/tridiag.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function (::Type{SymTri})(A::AbstractMatrix) where {SymTri <: SymTridiagonal}
111111
checksquare(A)
112112
du = diag(A, 1)
113113
d = diag(A)
114-
if !(A isa Symmetric || _checksymmetric(d, du, diag(A, -1)))
114+
if !(_issymmetric(A) || _checksymmetric(d, du, diag(A, -1)))
115115
throw(ArgumentError("matrix is not symmetric; cannot convert to SymTridiagonal"))
116116
end
117117
return SymTri(d, du)

0 commit comments

Comments
 (0)