From b00fd9f4ab35247df0ee4ed987559f2fd52fcef7 Mon Sep 17 00:00:00 2001 From: Tommy Hofmann Date: Mon, 28 Aug 2023 10:45:02 +0200 Subject: [PATCH] Minor improvements (#1193) --- src/NumFieldOrd/NfOrd/Clgp/FacBase_Idl.jl | 2 +- src/NumFieldOrd/NfOrd/FracIdeal.jl | 4 ++-- src/NumFieldOrd/NfOrd/Ideal/Ideal.jl | 4 ++-- src/NumFieldOrd/NfOrd/NfOrd.jl | 2 +- src/QuadForm/Quad/ZLattices.jl | 14 +++++++++++--- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/NumFieldOrd/NfOrd/Clgp/FacBase_Idl.jl b/src/NumFieldOrd/NfOrd/Clgp/FacBase_Idl.jl index 32d68637ca..2ac850362d 100644 --- a/src/NumFieldOrd/NfOrd/Clgp/FacBase_Idl.jl +++ b/src/NumFieldOrd/NfOrd/Clgp/FacBase_Idl.jl @@ -29,7 +29,7 @@ function NfFactorBase(O::NfOrd, B::Int; end function NfFactorBase(O::NfOrd, lp::Vector{NfOrdIdl}) - lp = sort(lp, lt = function(a,b) return norm(a) > norm(b); end) + lp = sort(lp, lt = function(a,b) return norm(a, copy = false) > norm(b, copy = false); end) FB = NfFactorBase() FB.size = length(lp) FB.ideals = lp diff --git a/src/NumFieldOrd/NfOrd/FracIdeal.jl b/src/NumFieldOrd/NfOrd/FracIdeal.jl index 30145c8e3f..d6e63b6429 100644 --- a/src/NumFieldOrd/NfOrd/FracIdeal.jl +++ b/src/NumFieldOrd/NfOrd/FracIdeal.jl @@ -280,9 +280,9 @@ end ################################################################################ function Base.deepcopy_internal(x::NfAbsOrdFracIdl, dict::IdDict) - z = NfAbsOrdFracIdl(numerator(x), denominator(x)) + z = NfAbsOrdFracIdl(numerator(x, copy = false), denominator(x, copy = false)) if isdefined(x, :basis_matrix) - z.basis_matrix = deepcopy(x.basis_matrix) + z.basis_matrix = Base.deepcopy_internal(x.basis_matrix, dict) end return z end diff --git a/src/NumFieldOrd/NfOrd/Ideal/Ideal.jl b/src/NumFieldOrd/NfOrd/Ideal/Ideal.jl index 497f620f4f..e82b097092 100644 --- a/src/NumFieldOrd/NfOrd/Ideal/Ideal.jl +++ b/src/NumFieldOrd/NfOrd/Ideal/Ideal.jl @@ -294,12 +294,12 @@ Creates the ideal $(x, y)$ of $\mathcal O$. """ function ideal(O::NfAbsOrd, x::ZZRingElem, y::NfAbsOrdElem) @assert parent(y) === O - return NfAbsOrdIdl(deepcopy(x), deepcopy(y)) + return NfAbsOrdIdl(x, y) end function ideal(O::NfAbsOrd, x::Integer, y::NfAbsOrdElem) @assert parent(y) === O - return NfAbsOrdIdl(ZZRingElem(x), deepcopy(y)) + return NfAbsOrdIdl(ZZRingElem(x), y) end function ideal(O::NfAbsOrd) diff --git a/src/NumFieldOrd/NfOrd/NfOrd.jl b/src/NumFieldOrd/NfOrd/NfOrd.jl index f77a92bae2..bd576c3a39 100644 --- a/src/NumFieldOrd/NfOrd/NfOrd.jl +++ b/src/NumFieldOrd/NfOrd/NfOrd.jl @@ -339,7 +339,7 @@ Assuming that the order $\mathcal O$ contains the equation order $\mathbf Z[\alpha]$ of the ambient number field, this function returns the index $[ \mathcal O : \mathbf Z]$. """ -function index(O::NfAbsOrd; copy::Bool = true) +function index(O::NfAbsOrd; copy::Bool = false) if !isdefined(O, :index) i = gen_index(O) !isone(denominator(i)) && error("Order does not contain the equation order") diff --git a/src/QuadForm/Quad/ZLattices.jl b/src/QuadForm/Quad/ZLattices.jl index 3277406360..5e0b66f616 100644 --- a/src/QuadForm/Quad/ZLattices.jl +++ b/src/QuadForm/Quad/ZLattices.jl @@ -1363,6 +1363,16 @@ function Base.:(*)(L::ZZLat, a::RationalUnion) return a * L end +################################################################################ +# +# Canonical basis matrix +# +################################################################################ + +@attr FakeFmpqMat function _canonical_basis_matrix(L::ZZLat) + return hnf(FakeFmpqMat(basis_matrix(L))) +end + ################################################################################ # # Equality and hash @@ -1379,9 +1389,7 @@ function Base.:(==)(L1::ZZLat, L2::ZZLat) if V1 != V2 return false end - B1 = basis_matrix(L1) - B2 = basis_matrix(L2) - return hnf(FakeFmpqMat(B1)) == hnf(FakeFmpqMat(B2)) + return _canonical_basis_matrix(L1) == _canonical_basis_matrix(L2) end function Base.hash(L::ZZLat, u::UInt)