Skip to content

Commit

Permalink
Change return argument order of is_prime_power_with_data
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed May 28, 2023
1 parent 895f171 commit eb82d11
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/flint/fmpz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2967,20 +2967,20 @@ is_prime_power(q::Integer) = is_prime_power(ZZRingElem(q))
@doc raw"""
is_prime_power_with_data(q::IntegerUnion) -> Bool, ZZRingElem, Int
Returns a flag indicating whether $q$ is a prime power and integers $p, e$ such
Returns a flag indicating whether $q$ is a prime power and integers $e, p$ such
that $q = p^e$. If $q$ is a prime power, than $p$ is a prime.
"""
is_prime_power_with_data(::IntegerUnion)

function is_prime_power_with_data(q::ZZRingElem)
iszero(q) && return false, q, 1
e, a = _maximal_integer_root(q)
return isprime(a), a, e
return isprime(a), e, a
end

function is_prime_power_with_data(q::Integer)
e, a = _maximal_integer_root(ZZRingElem(q))
return isprime(a), typeof(q)(a), e
return isprime(a), e, typeof(q)(a)
end

###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion src/flint/fq_default_extended.jl
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ end
################################################################################

function NGFiniteField(a::IntegerUnion, s::VarName = :o; cached::Bool = true, check::Bool = true)
fl, p, e = is_prime_power_with_data(a)
fl, e, p = is_prime_power_with_data(a)
!fl && error("Order must be a prime power")
return NGFiniteField(p, e, s; cached = cached, check = false)
end
Expand Down
6 changes: 3 additions & 3 deletions test/flint/fmpz-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1157,11 +1157,11 @@ end
# Prime power
for T in [Int, BigInt, ZZRingElem]
@test @inferred Nemo.is_prime_power(T(2))
@test (@inferred Nemo.is_prime_power_with_data(T(2))) == (true, T(2), 1)
@test (@inferred Nemo.is_prime_power_with_data(T(2))) == (true, 1, T(2))
@test Nemo.is_prime_power(T(4))
@test (@inferred Nemo.is_prime_power_with_data(T(4))) == (true, T(2), 2)
@test (@inferred Nemo.is_prime_power_with_data(T(4))) == (true, 2, T(2))
@test Nemo.is_prime_power(T(27))
@test (@inferred Nemo.is_prime_power_with_data(T(27))) == (true, T(3), 3)
@test (@inferred Nemo.is_prime_power_with_data(T(27))) == (true, 3, T(3))
@test !Nemo.is_prime_power(T(1))
@test !Nemo.is_prime_power(T(6))
@test !Nemo.is_prime_power(T(-3))
Expand Down

0 comments on commit eb82d11

Please sign in to comment.