Skip to content

Commit

Permalink
Merge pull request #635 from ChristophHotter/adjoint_symbolics
Browse files Browse the repository at this point in the history
adjoint(y::Symbolic{<:Number})
  • Loading branch information
bowenszhu authored Aug 29, 2024
2 parents aab293a + 803c555 commit 2afe8b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ promote_symtype(::typeof(Base.conj), T::Type{<:Number}) = T
Base.conj(s::Symbolic{<:Number}) = islike(s, Real) ? s : term(conj, s)
promote_symtype(::typeof(Base.imag), T::Type{<:Number}) = Real
Base.imag(s::Symbolic{<:Number}) = islike(s, Real) ? zero(symtype(s)) : term(imag, s)
Base.adjoint(s::Symbolic{<:Number}) = conj(s)


## Booleans

Expand Down
8 changes: 8 additions & 0 deletions test/basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,11 @@ end
end
@test repr(sin(x) + sin(x)) == "sin(x) + sin(x)"
end

@testset "Adjoint" begin
@syms x::Real y
ax = adjoint(x)
@test isequal(ax, x)
@test ax === x
@test isequal(adjoint(y), conj(y))
end

0 comments on commit 2afe8b9

Please sign in to comment.