Skip to content

Commit ef324c9

Browse files
authored
Merge pull request #60 from jverzani/pull-request/3ed4f9e9
Pull request/3ed4f9e9
2 parents 6abfd7b + 3ed4f9e commit ef324c9

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/Polynomials.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ end
189189
"""
190190
norm(q::Poly, args...) = norm(coeffs(q), args...)
191191

192+
193+
"""
194+
195+
* `conj(p::Poly`): return conjugate of polynomial `p`. (Polynomial with conjugate of each coefficient.)
196+
197+
"""
198+
Base.conj{T<:Complex}(p::Poly{T}) = Poly(conj(coeffs(p)))
199+
192200
"""
193201
194202
* `getindex(p::Poly, i)`: If `p=a_n x^n + a_{n-1}x^{n-1} + ... + a_1 x^1 + a_0`, then `p[i]` returns `a_i`.

src/show.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function printterm{T<:Complex}(io::IO,p::Poly{T},j,first)
6262
end
6363
else
6464
if abs_impj > 2*eps(T)
65-
print(io,'(', imag(pj),"im)")
65+
print(io,'(', abs(imag(pj)),"im)")
6666
end
6767
end
6868
printexponent(io,p.var,j)

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,10 @@ p1 = Poly([4,5,6])
183183
@test all(p1[0:end] .== [4,5,6])
184184
p1[0:1] = [7,8]
185185
@test all(p1[0:end] .== [7,8,6])
186+
187+
188+
## conjugate of poly (issue #59)
189+
as = [im, 1, 2]
190+
bs = [1, 1, 2]
191+
@test conj(Poly(as)) == Poly(conj(as))
192+
@test conj(Poly(bs)) == Poly(conj(bs))

0 commit comments

Comments
 (0)