@@ -9,7 +9,7 @@ const monadic = [deg2rad, rad2deg, transpose, conj, asind, log1p, acsch,
99 abs2, cosh, sin, cos, atan, cospi, cbrt, acosd, acoth, acotd,
1010 asecd, exp, acot, sqrt, sind, sinpi, asech, log2, tan, exp10,
1111 sech, coth, asin, cotd, cosd, sinh, abs, csc, tanh, secd,
12- atand, sec, acscd, cot, exp2, expm1, atanh, real, gamma,
12+ atand, sec, acscd, cot, exp2, expm1, atanh, real, imag, gamma,
1313 loggamma, erf, erfc, erfcinv, erfi, erfcx, dawson, digamma,
1414 trigamma, invdigamma, polygamma, airyai, airyaiprime, airybi,
1515 airybiprime, besselj0, besselj1, bessely0, bessely1]
@@ -97,7 +97,7 @@ promote_symtype(::typeof(rem2pi), T::Type{<:Number}, mode) = T
9797Base. rem2pi (x:: Symbolic{<:Number} , mode:: Base.RoundingMode ) = term (rem2pi, x, mode)
9898
9999for f in monadic
100- if f in [real]
100+ if f in [real, imag, conj ]
101101 continue
102102 end
103103 @eval promote_symtype (:: $ (typeof (f)), T:: Type{<:Number} ) = promote_type (T, Real)
@@ -111,8 +111,15 @@ for f in [identity, one, zero, *, +, -]
111111 @eval promote_symtype (:: $ (typeof (f)), T:: Type{<:Number} ) = T
112112end
113113
114+ # All of these need to be `Sym` to overwrite the function definitions of
115+ # the L78, that are made with the type `Sym <: Symbolic`
116+ # @number_methods(Sym, term(f, a), term(f, a, b), skipbasics)
114117promote_symtype (:: typeof (Base. real), T:: Type{<:Number} ) = Real
115- Base. real (s:: Symbolic{<:Number} ) = islike (s, Real) ? s : term (real, s)
118+ Base. real (s:: Sym{<:Real} ) = s
119+ promote_symtype (:: typeof (Base. conj), T:: Type{<:Number} ) = T
120+ Base. conj (s:: Sym{<:Real} ) = s
121+ promote_symtype (:: typeof (Base. imag), T:: Type{<:Number} ) = Real
122+ Base. imag (s:: Sym{<:Real} ) = zero (symtype (s))
116123
117124# # Booleans
118125
0 commit comments