-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move more obvious piracy from Hecke to Nemo
- Loading branch information
1 parent
fc4b618
commit ab672f0
Showing
5 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
function copy(a::ZZRingElem) | ||
return deepcopy(a) | ||
end | ||
|
||
function QQMatrix(x::ZZMatrix) | ||
z = zero_matrix(FlintQQ, nrows(x), ncols(x)) | ||
ccall((:fmpq_mat_set_fmpz_mat, libflint), Nothing, (Ref{QQMatrix}, Ref{ZZMatrix}), z, x) | ||
return z | ||
end | ||
|
||
function round(::Type{Int}, a::QQFieldElem) | ||
return round(Int, Rational{BigInt}(a)) | ||
end | ||
|
||
function matrix(a::Vector{Vector{T}}) where {T} | ||
return matrix(permutedims(reduce(hcat, a), (2, 1))) | ||
end | ||
|
||
function prime_field(_::NumField) | ||
return QQField() | ||
end | ||
|
||
function prime_field(F::fqPolyRepField; cached::Bool=true) | ||
return Native.GF(Int(characteristic(F)), cached=cached) | ||
end | ||
|
||
function prime_field(F::FqPolyRepField; cached::Bool=true) | ||
return Native.GF(characteristic(F), cached=cached) | ||
end | ||
|
||
function prime_field(F::T; cached::Bool=true) where {T<:Union{fpField,FpField}} | ||
return F | ||
end | ||
|
||
function evaluate(f::ZZPolyRingElem, r::fqPolyRepFieldElem) | ||
#Horner - stolen from Claus | ||
|
||
if length(f) == 0 | ||
return parent(r)() | ||
end | ||
|
||
l = f.length - 1 | ||
s = parent(r)(coeff(f, l)) | ||
for i = l-1:-1:0 | ||
s = s * r + parent(r)(coeff(f, i)) | ||
end | ||
return s | ||
end | ||
|
||
function evaluate!(z::fqPolyRepFieldElem, f::ZZPolyRingElem, r::fqPolyRepFieldElem) | ||
#Horner - stolen from Claus | ||
|
||
zero!(z) | ||
|
||
if length(f) == 0 | ||
return z | ||
end | ||
|
||
l = f.length - 1 | ||
set!(z, parent(r)(coeff(f, l))) | ||
#s = parent(r)(coeff(f, l)) | ||
for i = l-1:-1:0 | ||
mul!(z, z, r) | ||
add!(z, z, parent(r)(coeff(f, i))) | ||
#s = s*r + parent(r)(coeff(f, i)) | ||
end | ||
return z | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters