diff --git a/src/flint/FlintTypes.jl b/src/flint/FlintTypes.jl index 0d491dfd2..d689098f2 100644 --- a/src/flint/FlintTypes.jl +++ b/src/flint/FlintTypes.jl @@ -5574,78 +5574,54 @@ mutable struct FqMatrix <: MatElem{FqFieldElem} function FqMatrix(r::Int, c::Int, arr::AbstractMatrix{FqFieldElem}, ctx::FqField) z = FqMatrix(r, c, ctx) - for i = 1:r - for j = 1:c - ccall((:fq_default_mat_entry_set, libflint), Nothing, - (Ref{FqMatrix}, Int, Int, Ref{FqFieldElem}, - Ref{FqField}), - 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 FqMatrix(r::Int, c::Int, arr::AbstractVector{FqFieldElem}, ctx::FqField) z = FqMatrix(r, c, ctx) - for i = 1:r - for j = 1:c - ccall((:fq_default_mat_entry_set, libflint), Nothing, - (Ref{FqMatrix}, Int, Int, Ref{FqFieldElem}, - Ref{FqField}), - 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 FqMatrix(r::Int, c::Int, arr::AbstractMatrix{ZZRingElem}, ctx::FqField) z = FqMatrix(r, c, ctx) - for i = 1:r - for j = 1:c - ccall((:fq_default_mat_entry_set_fmpz, libflint), Nothing, - (Ref{FqMatrix}, Int, Int, Ref{ZZRingElem}, - Ref{FqField}), - 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 FqMatrix(r::Int, c::Int, arr::AbstractVector{ZZRingElem}, ctx::FqField) z = FqMatrix(r, c, ctx) - for i = 1:r - for j = 1:c - ccall((:fq_default_mat_entry_set_fmpz, libflint), Nothing, - (Ref{FqMatrix}, Int, Int, Ref{ZZRingElem}, - Ref{FqField}), - 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 FqMatrix(r::Int, c::Int, arr::AbstractMatrix{T}, ctx::FqField) where {T <: Integer} z = FqMatrix(r, c, ctx) - for i = 1:r - for j = 1:c - ccall((:fq_default_mat_entry_set, libflint), Nothing, - (Ref{FqMatrix}, Int, Int, Ref{FqFieldElem}, - Ref{FqField}), - 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 FqMatrix(r::Int, c::Int, arr::AbstractVector{T}, ctx::FqField) where {T <: Integer} z = FqMatrix(r, c, ctx) - for i = 1:r - for j = 1:c - ccall((:fq_default_mat_entry_set, libflint), Nothing, - (Ref{FqMatrix}, Int, Int, Ref{FqFieldElem}, - Ref{FqField}), - 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 @@ -5654,9 +5630,7 @@ mutable struct FqMatrix <: MatElem{FqFieldElem} ctx = parent(d) z = FqMatrix(r, c, ctx) for i = 1:min(r, c) - ccall((:fq_default_mat_entry_set, libflint), Nothing, - (Ref{FqMatrix}, Int, Int, Ref{FqFieldElem}, - Ref{FqField}), z, i - 1, i - 1, d, ctx) + @inbounds z[i, i] = d end return z end diff --git a/src/flint/fq_default_mat.jl b/src/flint/fq_default_mat.jl index 3c114c6ae..161f31323 100644 --- a/src/flint/fq_default_mat.jl +++ b/src/flint/fq_default_mat.jl @@ -45,14 +45,11 @@ end return z end -@inline function setindex!(a::FqMatrix, u::FqFieldElem, i::Int, j::Int) +@inline function setindex!(a::FqMatrix, u::FqFieldElemOrPtr, i::Int, j::Int) @boundscheck _checkbounds(a, i, j) - K = base_ring(a) - uu = K(u) - ccall((:fq_default_mat_entry_set, libflint), Nothing, - (Ref{FqMatrix}, Int, Int, Ref{FqFieldElem}, Ref{FqField}), - a, i - 1, j - 1, uu, base_ring(a)) - nothing + @ccall libflint.fq_default_mat_entry_set( + a::Ref{FqMatrix}, i-1::Int, j-1::Int, u::Ref{FqFieldElem}, base_ring(a)::Ref{FqField} + )::Nothing end @inline function setindex!(a::FqMatrix, u::ZZRingElem, i::Int, j::Int)