Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise check_parent for ResElem and ResFieldElem #1741

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/Residue.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@ function is_exact_type(a::Type{T}) where {S <: RingElement, T <: ResElem{S}}
return is_exact_type(S)
end

function check_parent_type(a::ResidueRing{T}, b::ResidueRing{T}) where {T <: RingElement}
# exists only to check types of parents agree
end

function check_parent(a::ResElem, b::ResElem, throw::Bool = true)
if parent(a) != parent(b)
check_parent_type(parent(a), parent(b))
fl = modulus(parent(a)) != modulus(parent(b))
fl && throw && error("Incompatible moduli in residue operation")
return !fl
Ra = parent(a)
Rb = parent(b)
if Ra != Rb
fl = typeof(Ra) == typeof(Rb) && modulus(Ra) == modulus(Rb)
!fl && throw && error("Incompatible moduli in residue operation")
#CF: maybe extend to divisibility?
return fl
end
return true
end
Expand Down
16 changes: 7 additions & 9 deletions src/ResidueField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ function is_exact_type(a::Type{T}) where {S <: RingElement, T <: ResFieldElem{S}
return is_exact_type(S)
end

function check_parent_type(a::ResidueField{T}, b::ResidueField{T}) where {T <: RingElement}
# exists only to check types of parents agree
end

function check_parent(a::ResFieldElem, b::ResFieldElem, throw::Bool = true)
if parent(a) != parent(b)
check_parent_type(parent(a), parent(b))
fl = modulus(parent(a)) != modulus(parent(b))
fl && throw && error("Incompatible moduli in residue operation") #CF: maybe extend to divisibility?
return !fl
Ra = parent(a)
Rb = parent(b)
if Ra != Rb
fl = typeof(Ra) == typeof(Rb) && modulus(Ra) == modulus(Rb)
!fl && throw && error("Incompatible moduli in residue operation")
#CF: maybe extend to divisibility?
return fl
end
return true
end
Expand Down
Loading