diff --git a/src/flint/FlintTypes.jl b/src/flint/FlintTypes.jl index d689098f2..e36b11d1e 100644 --- a/src/flint/FlintTypes.jl +++ b/src/flint/FlintTypes.jl @@ -5827,72 +5827,54 @@ mutable struct fqPolyRepMatrix <: MatElem{fqPolyRepFieldElem} function fqPolyRepMatrix(r::Int, c::Int, arr::AbstractMatrix{fqPolyRepFieldElem}, ctx::fqPolyRepField) z = fqPolyRepMatrix(r, c, ctx) - GC.@preserve z for i = 1:r - for j = 1:c - ccall((:fq_nmod_mat_entry_set, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Int, Int, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, i - 1, j - 1, arr[i, j], ctx) - end + for i = 1:r, j = 1:c + el = arr[i, j] + @inbounds z[i, j] = el end return z end function fqPolyRepMatrix(r::Int, c::Int, arr::AbstractVector{fqPolyRepFieldElem}, ctx::fqPolyRepField) z = fqPolyRepMatrix(r, c, ctx) - GC.@preserve z for i = 1:r - for j = 1:c - ccall((:fq_nmod_mat_entry_set, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Int, Int, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, i - 1, j - 1, arr[(i - 1) * c + j], ctx) - end + for i = 1:r, j = 1:c + el = arr[(i - 1) * c + j] + @inbounds z[i, j] = el end return z end function fqPolyRepMatrix(r::Int, c::Int, arr::AbstractMatrix{ZZRingElem}, ctx::fqPolyRepField) z = fqPolyRepMatrix(r, c, ctx) - GC.@preserve z for i = 1:r - for j = 1:c - el = mat_entry_ptr(z, i, j) - ccall((:fq_nmod_set_fmpz, libflint), Nothing, - (Ptr{fqPolyRepFieldElem}, Ref{ZZRingElem}, Ref{fqPolyRepField}), el, arr[i, j], ctx) - end + for i = 1:r, j = 1:c + el = arr[i, j] + @inbounds z[i, j] = el end return z end function fqPolyRepMatrix(r::Int, c::Int, arr::AbstractVector{ZZRingElem}, ctx::fqPolyRepField) z = fqPolyRepMatrix(r, c, ctx) - GC.@preserve z for i = 1:r - for j = 1:c - el = mat_entry_ptr(z, i, j) - ccall((:fq_nmod_set_fmpz, libflint), Nothing, - (Ptr{fqPolyRepFieldElem}, Ref{ZZRingElem}, Ref{fqPolyRepField}), el, arr[(i - 1) * c + j], ctx) - end + for i = 1:r, j = 1:c + el = arr[(i - 1) * c + j] + @inbounds z[i, j] = el end return z end function fqPolyRepMatrix(r::Int, c::Int, arr::AbstractMatrix{T}, ctx::fqPolyRepField) where {T <: Integer} z = fqPolyRepMatrix(r, c, ctx) - GC.@preserve z for i = 1:r - for j = 1:c - ccall((:fq_nmod_mat_entry_set, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Int, Int, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, i - 1, j - 1, ctx(arr[i, j]), ctx) - end + for i = 1:r, j = 1:c + el = ctx(arr[i, j]) + @inbounds z[i, j] = el end return z end function fqPolyRepMatrix(r::Int, c::Int, arr::AbstractVector{T}, ctx::fqPolyRepField) where {T <: Integer} z = fqPolyRepMatrix(r, c, ctx) - GC.@preserve z for i = 1:r - for j = 1:c - ccall((:fq_nmod_mat_entry_set, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Int, Int, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, i - 1, j - 1, ctx(arr[(i - 1) * c + j]), ctx) - end + for i = 1:r, j = 1:c + el = ctx(arr[(i - 1) * c + j]) + @inbounds z[i, j] = el end return z end @@ -5901,8 +5883,7 @@ mutable struct fqPolyRepMatrix <: MatElem{fqPolyRepFieldElem} ctx = parent(d) z = fqPolyRepMatrix(r, c, ctx) for i = 1:min(r, c) - ccall((:fq_nmod_mat_entry_set, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Int, Int, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), z, i - 1, i- 1, d, ctx) + @inbounds z[i, i] = d end return z end diff --git a/src/flint/fq_nmod_mat.jl b/src/flint/fq_nmod_mat.jl index 20dd55a16..c44bb26aa 100644 --- a/src/flint/fq_nmod_mat.jl +++ b/src/flint/fq_nmod_mat.jl @@ -47,11 +47,11 @@ end return z end -@inline function setindex!(a::fqPolyRepMatrix, u::fqPolyRepFieldElem, i::Int, j::Int) +@inline function setindex!(a::fqPolyRepMatrix, u::fqPolyRepFieldElemOrPtr, i::Int, j::Int) @boundscheck _checkbounds(a, i, j) - ccall((:fq_nmod_mat_entry_set, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Int, Int, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - a, i - 1, j - 1, u, base_ring(a)) + @ccall libflint.fq_nmod_mat_entry_set( + a::Ref{fqPolyRepMatrix}, (i-1)::Int, (j-1)::Int, u::Ref{fqPolyRepFieldElem}, base_ring(a)::Ref{fqPolyRepField} + )::Nothing end @inline function setindex!(a::fqPolyRepMatrix, u::ZZRingElem, i::Int, j::Int)