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

HACK: add faster arithmetic for UnivPoly and ZZRingElem #203

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
19 changes: 19 additions & 0 deletions src/GenericCyclotomics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,25 @@
return R(Dict(exponent => base_ring(R)(x)))
end

# TODO: move the following methods to Nemo
function *(p::Generic.UnivPoly{T, U}, n::ZZRingElem) where {T, U}
S = parent(p)
return Generic.UnivPoly{T, U}(p.p*n, S)
end

*(n::ZZRingElem, p::Generic.UnivPoly) = p*n

function -(p::Generic.UnivPoly{T, U}, n::ZZRingElem) where {T, U}
S = parent(p)
return Generic.UnivPoly{T, U}(p.p-n, S)
end

function -(n::ZZRingElem, p::Generic.UnivPoly{T, U}) where {T, U}
S = parent(p)
return Generic.UnivPoly{T, U}(n-p.p, S)

Check warning on line 431 in src/GenericCyclotomics.jl

View check run for this annotation

Codecov / codecov/patch

src/GenericCyclotomics.jl#L429-L431

Added lines #L429 - L431 were not covered by tests
end


function (R::GenericCycloRing)(f::Dict{UPolyFrac, UPoly}; simplify::Bool=true) # TODO check parent rings?
if !simplify
return GenericCyclo(f, R)
Expand Down
Loading