Skip to content

Commit

Permalink
Revert "Revert "QQBar: construct from any Integer or Complex value"" (#…
Browse files Browse the repository at this point in the history
…1725)

Revert "Revert "QQBar: construct from any Integer or Complex value (#1702)" (…"

This reverts commit 52e8e07.
  • Loading branch information
lgoettgens authored Apr 30, 2024
1 parent 4beb832 commit f8217f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/calcium/qqbar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function QQBarFieldElem(a::Int)
return z
end

function QQBarFieldElem(a::Complex{Int})
function QQBarFieldElem(a::Complex)
r = QQBarFieldElem(real(a))
s = QQBarFieldElem(imag(a))
z = QQBarFieldElem()
Expand All @@ -75,6 +75,8 @@ end

QQBarFieldElem(a::Rational) = QQBarFieldElem(QQFieldElem(a))

QQBarFieldElem(a::Integer) = QQBarFieldElem(ZZRingElem(a))

function deepcopy_internal(a::QQBarFieldElem, dict::IdDict)
z = QQBarFieldElem()
ccall((:qqbar_set, libcalcium), Nothing, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a)
Expand Down Expand Up @@ -1519,17 +1521,7 @@ end

(a::QQBarField)() = QQBarFieldElem()

(a::QQBarField)(b::Int) = QQBarFieldElem(b)

(a::QQBarField)(b::Complex{Int}) = QQBarFieldElem(b)

(a::QQBarField)(b::ZZRingElem) = QQBarFieldElem(b)

(a::QQBarField)(b::Integer) = QQBarFieldElem(ZZRingElem(b))

(a::QQBarField)(b::Rational) = QQBarFieldElem(b)

(a::QQBarField)(b::QQFieldElem) = QQBarFieldElem(b)
(a::QQBarField)(b::Any) = QQBarFieldElem(b)

(a::QQBarField)(b::QQBarFieldElem) = b

Expand Down
6 changes: 6 additions & 0 deletions test/calcium/qqbar-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@

@test isa(R(), QQBarFieldElem)
@test isa(R(2), QQBarFieldElem)
@test isa(R(big(2)), QQBarFieldElem)
@test isa(R(2+3im), QQBarFieldElem)
@test isa(R(big(2)+3im), QQBarFieldElem)
@test isa(R(ZZRingElem(2)), QQBarFieldElem)
@test isa(R(QQFieldElem(2)), QQBarFieldElem)
@test isa(R(QQBarFieldElem(2)), QQBarFieldElem)
@test isa(R(1//2), QQBarFieldElem)
@test isa(R(big(1)//2), QQBarFieldElem)
@test R(1//2) == R(QQ(1//2))

@test isa(QQBarFieldElem(), QQBarFieldElem)
@test isa(QQBarFieldElem(2), QQBarFieldElem)
@test isa(QQBarFieldElem(big(2)), QQBarFieldElem)
@test isa(QQBarFieldElem(2+3im), QQBarFieldElem)
@test isa(QQBarFieldElem(big(2)+3im), QQBarFieldElem)
@test isa(QQBarFieldElem(ZZRingElem(2)), QQBarFieldElem)
@test isa(QQBarFieldElem(QQFieldElem(2)), QQBarFieldElem)
@test isa(QQBarFieldElem(1//2), QQBarFieldElem)
@test isa(QQBarFieldElem(big(1)//2), QQBarFieldElem)
@test QQBarFieldElem(1//2) == QQBarFieldElem(QQ(1//2))

x = R(1)
Expand Down

0 comments on commit f8217f7

Please sign in to comment.