Skip to content

Commit

Permalink
Merge pull request #10 from heltonmc/conj
Browse files Browse the repository at this point in the history
Add complex vector conjugate
  • Loading branch information
heltonmc authored Apr 18, 2023
2 parents 6d2955e + c9450f1 commit 848a7e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ end
@inline fadd(x::Union{T, Complex{T}}, y::Union{T, Complex{T}}) where T = x + y
@inline fsub(x::Union{T, Complex{T}}, y::Union{T, Complex{T}}) where T = x - y
@inline fneg(x::Union{T, Complex{T}}) where T = -x

# conjugate
@inline Base.conj(z::ComplexVec{N, FloatTypes}) where {N, FloatTypes} = ComplexVec{N, FloatTypes}(z.re, fneg(z.im))
9 changes: 9 additions & 0 deletions test/complex_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ end

@test convert(ComplexVec{4, Float64}, 1.2) == ComplexVec{4, Float64}((1.2, 1.2, 1.2, 1.2), (0.0, 0.0, 0.0, 0.0))

# test conjugate
let
c = (1.1 + 1.4im, 1.3 - 1.2im)
cv = ComplexVec{2, Float64}((1.1, 1.3), (1.4, -1.2))
cconj = conj(cv)
@test cconj[1] == conj(c[1])
@test cconj[2] == conj(c[2])
end

P1 = (1.1, 1.2, 1.4, 1.5, 1.3, 1.4, 1.5, 1.6, 1.7, 1.2, 1.2, 2.1, 3.1, 1.4, 1.5)
P2 = (1.1, 1.2, 1.4, 1.53, 1.32, 1.41, 1.52, 1.64, 1.4, 1.0, 1.6, 2.5, 3.1, 1.9, 1.2)
pp3 = pack_poly((P1, P2))
Expand Down

0 comments on commit 848a7e9

Please sign in to comment.