Skip to content

Commit

Permalink
Define conj and conj! for for Symmetric and Hermitian. (#17827)
Browse files Browse the repository at this point in the history
Fixes #17780
  • Loading branch information
andreasnoack authored and tkelman committed Aug 10, 2016
1 parent 35df9b8 commit 3f6b2b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions base/linalg/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ end
ctranspose(A::Hermitian) = A
trace(A::Hermitian) = real(trace(A.data))

Base.conj(A::HermOrSym) = typeof(A)(conj(A.data), A.uplo)
Base.conj!(A::HermOrSym) = typeof(A)(conj!(A.data), A.uplo)

#tril/triu
function tril(A::Hermitian, k::Integer=0)
if A.uplo == 'U' && k <= 0
Expand Down
14 changes: 14 additions & 0 deletions test/linalg/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,17 @@ let A = Symmetric(randn(5,5))
B = -A
@test A + B zeros(5,5)
end

# 17780
let a = randn(2,2)
a = a'a
b = complex(a,a)
c = Symmetric(b)
@test conj(c) == conj(Array(c))
cc = copy(c)
@test conj!(c) == conj(Array(cc))
c = Hermitian(b + b')
@test conj(c) == conj(Array(c))
cc = copy(c)
@test conj!(c) == conj(Array(c))
end

0 comments on commit 3f6b2b2

Please sign in to comment.