Skip to content

Commit

Permalink
feat: add copy keyword to basis of fractional ideals (#1579)
Browse files Browse the repository at this point in the history
- Closes #1578
  • Loading branch information
thofma authored Aug 17, 2024
1 parent 1a438c4 commit ffa4484
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/HeckeTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ mutable struct AbsNumFieldOrderFractionalIdeal{S, T} <: NumFieldOrderFractionalI
norm::QQFieldElem
basis_matrix::FakeFmpqMat
basis_mat_inv::FakeFmpqMat
basis::Vector{T}

function AbsNumFieldOrderFractionalIdeal{S, T}(O::AbsNumFieldOrder{S, T}) where {S, T}
z = new{S, T}()
Expand Down
8 changes: 6 additions & 2 deletions src/NumFieldOrd/NfOrd/FracIdeal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ end
Returns the $\mathbf Z$-basis of $I$.
"""
function basis(a::AbsNumFieldOrderFractionalIdeal{S, T}) where {S, T}
function basis(a::AbsNumFieldOrderFractionalIdeal{S, T}; copy::Bool = true) where {S, T}
if isdefined(a, :basis)
copy && return Base.copy(a.basis)
return a.basis
end
B = basis_matrix(FakeFmpqMat, a; copy = false)
d = degree(order(a))
O = order(a)
Expand All @@ -263,7 +267,7 @@ function basis(a::AbsNumFieldOrderFractionalIdeal{S, T}) where {S, T}
z = divexact(z, B.den)
res[i] = z
end

a.basis = res
return res
end

Expand Down
4 changes: 4 additions & 0 deletions test/NfOrd/FracIdl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ K3, (a3,) = number_field([x^3 - 2], "a2")
@test b == [ K1(8), a1, 2*a1^2 ]
b = @inferred basis(M)
@test b == [ K1(8), a1, 2*a1^2 ]

b = basis(J)
@test b !== basis(J)
@test basis(J, copy = false) === basis(J, copy = false)
end

@testset "Norm" begin
Expand Down

0 comments on commit ffa4484

Please sign in to comment.