Skip to content

Commit

Permalink
Drop r and c from some matrix constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Oct 25, 2024
1 parent f83e47e commit d9943c1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 54 deletions.
21 changes: 12 additions & 9 deletions src/flint/FlintTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5572,11 +5572,12 @@ mutable struct FqMatrix <: MatElem{FqFieldElem}
return z
end

function FqMatrix(r::Int, c::Int, arr::AbstractMatrix{<:Union{FqFieldElem,ZZRingElem,Integer}}, ctx::FqField)
function FqMatrix(arr::AbstractMatrix{<:Union{FqFieldElem,ZZRingElem,Integer}}, ctx::FqField)
r = nrows(arr)
c = ncols(arr)
z = FqMatrix(r, c, ctx)
for i = 1:r, j = 1:c
el = arr[i, j]
@inbounds z[i, j] = el
@inbounds z[i, j] = arr[i, j]
end
return z
end
Expand Down Expand Up @@ -5675,11 +5676,12 @@ mutable struct FqPolyRepMatrix <: MatElem{FqPolyRepFieldElem}
return z
end

function FqPolyRepMatrix(r::Int, c::Int, arr::AbstractMatrix{<:Union{FqPolyRepFieldElem,ZZRingElem,Integer}}, ctx::FqPolyRepField)
function FqPolyRepMatrix(arr::AbstractMatrix{<:Union{FqPolyRepFieldElem,ZZRingElem,Integer}}, ctx::FqPolyRepField)
r = nrows(arr)
c = ncols(arr)
z = FqPolyRepMatrix(r, c, ctx)
for i = 1:r, j = 1:c
el = arr[i, j]
@inbounds z[i, j] = el
@inbounds z[i, j] = arr[i, j]
end
return z
end
Expand Down Expand Up @@ -5753,11 +5755,12 @@ mutable struct fqPolyRepMatrix <: MatElem{fqPolyRepFieldElem}
return z
end

function fqPolyRepMatrix(r::Int, c::Int, arr::AbstractMatrix{<:Union{fqPolyRepFieldElem,ZZRingElem,Integer}}, ctx::fqPolyRepField)
function fqPolyRepMatrix(arr::AbstractMatrix{<:Union{fqPolyRepFieldElem,ZZRingElem,Integer}}, ctx::fqPolyRepField)
r = nrows(arr)
c = ncols(arr)
z = fqPolyRepMatrix(r, c, ctx)
for i = 1:r, j = 1:c
el = arr[i, j]
@inbounds z[i, j] = el
@inbounds z[i, j] = arr[i, j]
end
return z
end
Expand Down
21 changes: 6 additions & 15 deletions src/flint/fq_default_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -674,30 +674,20 @@ function (a::FqMatrixSpace)(b::FqFieldElem)
return FqMatrix(nrows(a), ncols(a), b)
end

function (a::FqMatrixSpace)(arr::AbstractMatrix{T}) where {T <: Integer}
function (a::FqMatrixSpace)(arr::AbstractMatrix{<:IntegerUnion})
_check_dim(nrows(a), ncols(a), arr)
return FqMatrix(nrows(a), ncols(a), arr, base_ring(a))
end

function (a::FqMatrixSpace)(arr::AbstractVector{T}) where {T <: Integer}
_check_dim(nrows(a), ncols(a), arr)
return FqMatrix(nrows(a), ncols(a), arr, base_ring(a))
return FqMatrix(arr, base_ring(a))
end

function (a::FqMatrixSpace)(arr::AbstractMatrix{ZZRingElem})
_check_dim(nrows(a), ncols(a), arr)
return FqMatrix(nrows(a), ncols(a), arr, base_ring(a))
end

function (a::FqMatrixSpace)(arr::AbstractVector{ZZRingElem})
function (a::FqMatrixSpace)(arr::AbstractVector{<:IntegerUnion})
_check_dim(nrows(a), ncols(a), arr)
return FqMatrix(nrows(a), ncols(a), arr, base_ring(a))
end

function (a::FqMatrixSpace)(arr::AbstractMatrix{FqFieldElem})
_check_dim(nrows(a), ncols(a), arr)
(length(arr) > 0 && (base_ring(a) != parent(arr[1]))) && error("Elements must have same base ring")
return FqMatrix(nrows(a), ncols(a), arr, base_ring(a))
return FqMatrix(arr, base_ring(a))
end

function (a::FqMatrixSpace)(arr::AbstractVector{FqFieldElem})
Expand Down Expand Up @@ -732,7 +722,8 @@ end
###############################################################################

function matrix(R::FqField, arr::AbstractMatrix{<: Union{FqFieldElem, ZZRingElem, Integer}})
z = FqMatrix(size(arr, 1), size(arr, 2), arr, R)
Base.require_one_based_indexing(arr)
z = FqMatrix(arr, R)
return z
end

Expand Down
21 changes: 6 additions & 15 deletions src/flint/fq_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -667,30 +667,20 @@ function (a::FqPolyRepMatrixSpace)(b::FqPolyRepFieldElem)
return FqPolyRepMatrix(nrows(a), ncols(a), b)
end

function (a::FqPolyRepMatrixSpace)(arr::AbstractMatrix{T}) where {T <: Integer}
function (a::FqPolyRepMatrixSpace)(arr::AbstractMatrix{<:IntegerUnion})
_check_dim(nrows(a), ncols(a), arr)
return FqPolyRepMatrix(nrows(a), ncols(a), arr, base_ring(a))
end

function (a::FqPolyRepMatrixSpace)(arr::AbstractVector{T}) where {T <: Integer}
_check_dim(nrows(a), ncols(a), arr)
return FqPolyRepMatrix(nrows(a), ncols(a), arr, base_ring(a))
return FqPolyRepMatrix(arr, base_ring(a))
end

function (a::FqPolyRepMatrixSpace)(arr::AbstractMatrix{ZZRingElem})
_check_dim(nrows(a), ncols(a), arr)
return FqPolyRepMatrix(nrows(a), ncols(a), arr, base_ring(a))
end

function (a::FqPolyRepMatrixSpace)(arr::AbstractVector{ZZRingElem})
function (a::FqPolyRepMatrixSpace)(arr::AbstractVector{<:IntegerUnion})
_check_dim(nrows(a), ncols(a), arr)
return FqPolyRepMatrix(nrows(a), ncols(a), arr, base_ring(a))
end

function (a::FqPolyRepMatrixSpace)(arr::AbstractMatrix{FqPolyRepFieldElem})
_check_dim(nrows(a), ncols(a), arr)
(length(arr) > 0 && (base_ring(a) != parent(arr[1]))) && error("Elements must have same base ring")
return FqPolyRepMatrix(nrows(a), ncols(a), arr, base_ring(a))
return FqPolyRepMatrix(arr, base_ring(a))
end

function (a::FqPolyRepMatrixSpace)(arr::AbstractVector{FqPolyRepFieldElem})
Expand All @@ -711,7 +701,8 @@ end
###############################################################################

function matrix(R::FqPolyRepField, arr::AbstractMatrix{<: Union{FqPolyRepFieldElem, ZZRingElem, Integer}})
z = FqPolyRepMatrix(size(arr, 1), size(arr, 2), arr, R)
Base.require_one_based_indexing(arr)
z = FqPolyRepMatrix(arr, R)
return z
end

Expand Down
21 changes: 6 additions & 15 deletions src/flint/fq_nmod_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -656,30 +656,20 @@ function (a::fqPolyRepMatrixSpace)(b::fqPolyRepFieldElem)
return fqPolyRepMatrix(nrows(a), ncols(a), b)
end

function (a::fqPolyRepMatrixSpace)(arr::AbstractMatrix{T}) where {T <: Integer}
function (a::fqPolyRepMatrixSpace)(arr::AbstractMatrix{<:IntegerUnion})
_check_dim(nrows(a), ncols(a), arr)
return fqPolyRepMatrix(nrows(a), ncols(a), arr, base_ring(a))
end

function (a::fqPolyRepMatrixSpace)(arr::AbstractVector{T}) where {T <: Integer}
_check_dim(nrows(a), ncols(a), arr)
return fqPolyRepMatrix(nrows(a), ncols(a), arr, base_ring(a))
return fqPolyRepMatrix(arr, base_ring(a))
end

function (a::fqPolyRepMatrixSpace)(arr::AbstractMatrix{ZZRingElem})
_check_dim(nrows(a), ncols(a), arr)
return fqPolyRepMatrix(nrows(a), ncols(a), arr, base_ring(a))
end

function (a::fqPolyRepMatrixSpace)(arr::AbstractVector{ZZRingElem})
function (a::fqPolyRepMatrixSpace)(arr::AbstractVector{<:IntegerUnion})
_check_dim(nrows(a), ncols(a), arr)
return fqPolyRepMatrix(nrows(a), ncols(a), arr, base_ring(a))
end

function (a::fqPolyRepMatrixSpace)(arr::AbstractMatrix{fqPolyRepFieldElem})
_check_dim(nrows(a), ncols(a), arr)
(length(arr) > 0 && (base_ring(a) != parent(arr[1]))) && error("Elements must have same base ring")
return fqPolyRepMatrix(nrows(a), ncols(a), arr, base_ring(a))
return fqPolyRepMatrix(arr, base_ring(a))
end

function (a::fqPolyRepMatrixSpace)(arr::AbstractVector{fqPolyRepFieldElem})
Expand All @@ -700,7 +690,8 @@ end
###############################################################################

function matrix(R::fqPolyRepField, arr::AbstractMatrix{<: Union{fqPolyRepFieldElem, ZZRingElem, Integer}})
z = fqPolyRepMatrix(size(arr, 1), size(arr, 2), arr, R)
Base.require_one_based_indexing(arr)
z = fqPolyRepMatrix(arr, R)
return z
end

Expand Down

0 comments on commit d9943c1

Please sign in to comment.