Skip to content

Commit 2afe8b9

Browse files
authored
Merge pull request #635 from ChristophHotter/adjoint_symbolics
adjoint(y::Symbolic{<:Number})
2 parents aab293a + 803c555 commit 2afe8b9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/methods.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ promote_symtype(::typeof(Base.conj), T::Type{<:Number}) = T
165165
Base.conj(s::Symbolic{<:Number}) = islike(s, Real) ? s : term(conj, s)
166166
promote_symtype(::typeof(Base.imag), T::Type{<:Number}) = Real
167167
Base.imag(s::Symbolic{<:Number}) = islike(s, Real) ? zero(symtype(s)) : term(imag, s)
168+
Base.adjoint(s::Symbolic{<:Number}) = conj(s)
169+
168170

169171
## Booleans
170172

test/basics.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,11 @@ end
357357
end
358358
@test repr(sin(x) + sin(x)) == "sin(x) + sin(x)"
359359
end
360+
361+
@testset "Adjoint" begin
362+
@syms x::Real y
363+
ax = adjoint(x)
364+
@test isequal(ax, x)
365+
@test ax === x
366+
@test isequal(adjoint(y), conj(y))
367+
end

0 commit comments

Comments
 (0)