Skip to content

Commit

Permalink
Minor improvements (#1193)
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma authored Aug 28, 2023
1 parent bb78886 commit b00fd9f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/NumFieldOrd/NfOrd/Clgp/FacBase_Idl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/NumFieldOrd/NfOrd/FracIdeal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/NumFieldOrd/NfOrd/Ideal/Ideal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/NumFieldOrd/NfOrd/NfOrd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
14 changes: 11 additions & 3 deletions src/QuadForm/Quad/ZLattices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit b00fd9f

Please sign in to comment.