Skip to content

Commit 3ed4f9e

Browse files
committed
add conj(p), fixes #59
1 parent 223de66 commit 3ed4f9e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
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`.

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)