Skip to content

Commit

Permalink
use UndefInitializer
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Nov 8, 2024
1 parent 4f905e5 commit 610018c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 38 deletions.
8 changes: 4 additions & 4 deletions src/arb/ArbTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ mutable struct RealMatrix <: MatElem{RealFieldElem}
#base_ring::ArbField

# MatElem interface
RealMatrix(::RealField, r::Int, c::Int) = RealMatrix(r, c)
RealMatrix(::RealField, ::UndefInitializer, r::Int, c::Int) = RealMatrix(r, c)

function RealMatrix(r::Int, c::Int)
z = new()
Expand Down Expand Up @@ -871,7 +871,7 @@ mutable struct ArbMatrix <: MatElem{ArbFieldElem}
base_ring::ArbField

# MatElem interface
function ArbMatrix(R::ArbField, r::Int, c::Int)
function ArbMatrix(R::ArbField, ::UndefInitializer, r::Int, c::Int)
z = ArbMatrix(r, c)
z.base_ring = R
return z
Expand Down Expand Up @@ -967,7 +967,7 @@ mutable struct ComplexMatrix <: MatElem{ComplexFieldElem}
#base_ring::AcbField

# MatElem interface
ComplexMatrix(::ComplexField, r::Int, c::Int) = ComplexMatrix(r, c)
ComplexMatrix(::ComplexField, ::UndefInitializer, r::Int, c::Int) = ComplexMatrix(r, c)

function ComplexMatrix(r::Int, c::Int)
z = new()
Expand Down Expand Up @@ -1155,7 +1155,7 @@ mutable struct AcbMatrix <: MatElem{AcbFieldElem}
base_ring::AcbField

# MatElem interface
function AcbMatrix(R::AcbField, r::Int, c::Int)
function AcbMatrix(R::AcbField, ::UndefInitializer, r::Int, c::Int)
z = AcbMatrix(r, c)
z.base_ring = R
return z
Expand Down
8 changes: 4 additions & 4 deletions src/arb/acb_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
###############################################################################

function similar(::AcbMatrix, R::AcbField, r::Int, c::Int)
z = AcbMatrix(R, r, c)
z = AcbMatrix(R, undef, r, c)
return z
end

Expand Down Expand Up @@ -693,7 +693,7 @@ end
###############################################################################

function (x::AcbMatrixSpace)()
z = AcbMatrix(base_ring(x), nrows(x), ncols(x))
z = AcbMatrix(base_ring(x), undef, nrows(x), ncols(x))
return z
end

Expand Down Expand Up @@ -838,7 +838,7 @@ function zero_matrix(R::AcbField, r::Int, c::Int)
if r < 0 || c < 0
error("dimensions must not be negative")
end
z = AcbMatrix(R, r, c)
z = AcbMatrix(R, undef, r, c)
return z
end

Expand All @@ -852,7 +852,7 @@ function identity_matrix(R::AcbField, n::Int)
if n < 0
error("dimension must not be negative")
end
return one!(AcbMatrix(R, n, n))
return one!(AcbMatrix(R, undef, n, n))
end

################################################################################
Expand Down
8 changes: 4 additions & 4 deletions src/arb/arb_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
###############################################################################

function similar(::ArbMatrix, R::ArbField, r::Int, c::Int)
z = ArbMatrix(R, r, c)
z = ArbMatrix(R, undef, r, c)
return z
end

Expand Down Expand Up @@ -78,7 +78,7 @@ number_of_rows(a::ArbMatrix) = a.r
number_of_columns(a::ArbMatrix) = a.c

function deepcopy_internal(x::ArbMatrix, dict::IdDict)
z = ArbMatrix(base_ring(x), nrows(x), ncols(x))
z = ArbMatrix(base_ring(x), undef, nrows(x), ncols(x))
@ccall libflint.arb_mat_set(z::Ref{ArbMatrix}, x::Ref{ArbMatrix})::Nothing
return z
end
Expand Down Expand Up @@ -736,7 +736,7 @@ function zero_matrix(R::ArbField, r::Int, c::Int)
if r < 0 || c < 0
error("dimensions must not be negative")
end
z = ArbMatrix(R, r, c)
z = ArbMatrix(R, undef, r, c)
return z
end

Expand All @@ -750,7 +750,7 @@ function identity_matrix(R::ArbField, n::Int)
if n < 0
error("dimension must not be negative")
end
return one!(ArbMatrix(R, n, n))
return one!(ArbMatrix(R, undef, n, n))
end

################################################################################
Expand Down
18 changes: 9 additions & 9 deletions src/flint/FlintTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4047,7 +4047,7 @@ mutable struct QQMatrix <: MatElem{QQFieldElem}
view_parent

# MatElem interface
QQMatrix(::QQField, r::Int, c::Int) = QQMatrix(r, c)
QQMatrix(::QQField, ::UndefInitializer, r::Int, c::Int) = QQMatrix(r, c)

# Used by view, not finalised!!
function QQMatrix()
Expand Down Expand Up @@ -4091,7 +4091,7 @@ mutable struct ZZMatrix <: MatElem{ZZRingElem}
view_parent

# MatElem interface
ZZMatrix(::ZZRing, r::Int, c::Int) = ZZMatrix(r, c)
ZZMatrix(::ZZRing, ::UndefInitializer, r::Int, c::Int) = ZZMatrix(r, c)

# Used by view, not finalised!!
function ZZMatrix()
Expand Down Expand Up @@ -4137,7 +4137,7 @@ mutable struct zzModMatrix <: MatElem{zzModRingElem}
view_parent

# MatElem interface
function zzModMatrix(R::zzModRing, r::Int, c::Int)
function zzModMatrix(R::zzModRing, ::UndefInitializer, r::Int, c::Int)
z = zzModMatrix(r, c, R.n)
z.base_ring = R
return z
Expand Down Expand Up @@ -4274,7 +4274,7 @@ mutable struct ZZModMatrix <: MatElem{ZZModRingElem}
view_parent

# MatElem interface
function ZZModMatrix(R::ZZModRing, r::Int, c::Int)
function ZZModMatrix(R::ZZModRing, ::UndefInitializer, r::Int, c::Int)
z = ZZModMatrix(r, c, R.ninv)
z.base_ring = R
return z
Expand Down Expand Up @@ -4425,7 +4425,7 @@ mutable struct FpMatrix <: MatElem{FpFieldElem}
view_parent

# MatElem interface
function FpMatrix(R::FpField, r::Int, c::Int)
function FpMatrix(R::FpField, ::UndefInitializer, r::Int, c::Int)
z = FpMatrix(r, c, R.ninv)
z.base_ring = R
return z
Expand Down Expand Up @@ -4530,7 +4530,7 @@ mutable struct fpMatrix <: MatElem{fpFieldElem}
view_parent

# MatElem interface
function fpMatrix(R::fpField, r::Int, c::Int)
function fpMatrix(R::fpField, ::UndefInitializer, r::Int, c::Int)
z = fpMatrix(r, c, R.n)
z.base_ring = R
return z
Expand Down Expand Up @@ -5017,7 +5017,7 @@ mutable struct FqMatrix <: MatElem{FqFieldElem}
view_parent

# MatElem interface
function FqMatrix(R::FqField, r::Int, c::Int)
function FqMatrix(R::FqField, ::UndefInitializer, r::Int, c::Int)
return FqMatrix(r, c, R)
end

Expand Down Expand Up @@ -5115,7 +5115,7 @@ mutable struct FqPolyRepMatrix <: MatElem{FqPolyRepFieldElem}
view_parent

# MatElem interface
function FqPolyRepMatrix(R::FqPolyRepField, r::Int, c::Int)
function FqPolyRepMatrix(R::FqPolyRepField, ::UndefInitializer, r::Int, c::Int)
return FqPolyRepMatrix(r, c, R)
end

Expand Down Expand Up @@ -5196,7 +5196,7 @@ mutable struct fqPolyRepMatrix <: MatElem{fqPolyRepFieldElem}
view_parent

# MatElem interface
function fqPolyRepMatrix(R::fqPolyRepField, r::Int, c::Int)
function fqPolyRepMatrix(R::fqPolyRepField, ::UndefInitializer, r::Int, c::Int)
return fqPolyRepMatrix(r, c, R)
end

Expand Down
8 changes: 4 additions & 4 deletions src/flint/fmpz_mod_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dense_matrix_type(::Type{ZZModRingElem}) = ZZModMatrix
###############################################################################

function similar(::MatElem, R::ZZModRing, r::Int, c::Int)
z = ZZModMatrix(R, r, c)
z = ZZModMatrix(R, undef, r, c)
return z
end

Expand Down Expand Up @@ -696,7 +696,7 @@ promote_rule(::Type{ZZModMatrix}, ::Type{ZZRingElem}) = ZZModMatrix
################################################################################

function (a::ZZModMatrixSpace)()
z = ZZModMatrix(base_ring(a), nrows(a), ncols(a))
z = ZZModMatrix(base_ring(a), undef, nrows(a), ncols(a))
return z
end

Expand Down Expand Up @@ -760,7 +760,7 @@ end

function (a::ZZModMatrixSpace)(b::ZZMatrix)
(ncols(a) != b.c || nrows(a) != b.r) && error("Dimensions do not fit")
z = ZZModMatrix(base_ring(a), b.r, b.c)
z = ZZModMatrix(base_ring(a), undef, b.r, b.c)
@ccall libflint.fmpz_mod_mat_set_fmpz_mat(z::Ref{ZZModMatrix}, b::Ref{ZZMatrix}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing
return z
end
Expand Down Expand Up @@ -794,7 +794,7 @@ function zero_matrix(R::ZZModRing, r::Int, c::Int)
if r < 0 || c < 0
error("dimensions must not be negative")
end
z = ZZModMatrix(R, r, c)
z = ZZModMatrix(R, undef, r, c)
return z
end

Expand Down
6 changes: 3 additions & 3 deletions src/flint/gfp_fmpz_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dense_matrix_type(::Type{FpFieldElem}) = FpMatrix
###############################################################################

function similar(::MatElem, R::FpField, r::Int, c::Int)
z = FpMatrix(R, r, c)
z = FpMatrix(R, undef, r, c)
return z
end

Expand Down Expand Up @@ -209,7 +209,7 @@ end
################################################################################

function (a::FpMatrixSpace)()
z = FpMatrix(base_ring(a), nrows(a), ncols(a))
z = FpMatrix(base_ring(a), undef, nrows(a), ncols(a))
return z
end

Expand Down Expand Up @@ -309,7 +309,7 @@ function zero_matrix(R::FpField, r::Int, c::Int)
if r < 0 || c < 0
error("dimensions must not be negative")
end
z = FpMatrix(R, r, c)
z = FpMatrix(R, undef, r, c)
return z
end

Expand Down
6 changes: 3 additions & 3 deletions src/flint/gfp_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dense_matrix_type(::Type{fpFieldElem}) = fpMatrix
###############################################################################

function similar(::fpMatrix, R::fpField, r::Int, c::Int)
z = fpMatrix(R, r, c)
z = fpMatrix(R, undef, r, c)
return z
end

Expand Down Expand Up @@ -281,7 +281,7 @@ end
################################################################################

function (a::fpMatrixSpace)()
z = fpMatrix(base_ring(a), nrows(a), ncols(a))
z = fpMatrix(base_ring(a), undef, nrows(a), ncols(a))
return z
end

Expand Down Expand Up @@ -379,7 +379,7 @@ function zero_matrix(R::fpField, r::Int, c::Int)
if r < 0 || c < 0
error("dimensions must not be negative")
end
z = fpMatrix(R, r, c)
z = fpMatrix(R, undef, r, c)
return z
end

Expand Down
10 changes: 3 additions & 7 deletions src/flint/nmod_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ dense_matrix_type(::Type{zzModRingElem}) = zzModMatrix
#
###############################################################################

function similar(::zzModMatrix, R::zzModRing, r::Int, c::Int)
z = zzModMatrix(R, r, c)
return z
end
similar(::zzModMatrix, R::zzModRing, r::Int, c::Int) = zzModMatrix(R, undef, r, c)

zero(m::zzModMatrix, R::zzModRing, r::Int, c::Int) = similar(m, R, r, c)

Expand Down Expand Up @@ -719,7 +716,7 @@ promote_rule(::Type{zzModMatrix}, ::Type{ZZRingElem}) = zzModMatrix
################################################################################

function (a::zzModMatrixSpace)()
z = zzModMatrix(base_ring(a), nrows(a), ncols(a))
z = zzModMatrix(base_ring(a), undef, nrows(a), ncols(a))
return z
end

Expand Down Expand Up @@ -817,8 +814,7 @@ function zero_matrix(R::zzModRing, r::Int, c::Int)
if r < 0 || c < 0
error("dimensions must not be negative")
end
z = zzModMatrix(R, r, c)
return z
return zzModMatrix(R, undef, r, c)
end

################################################################################
Expand Down

0 comments on commit 610018c

Please sign in to comment.