Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more convencience methods for arithmetics with Vector{QQFieldElem} #1559

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/flint/fmpq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1205,14 +1205,20 @@ Rational(z::ZZRingElem) = Rational{BigInt}(z)

###############################################################################
#
# Convenience methods for arithmetics (since `QQFieldElem` is not a `Number` type)
# Convenience methods for arithmetics (since `QQFieldElem` and `ZZRingElem` are not `Number` types)
#
###############################################################################

//(v::Vector{QQFieldElem}, x::QQFieldElem) = v .// x
/(v::Vector{QQFieldElem}, x::QQFieldElem) = v ./ x
*(x::QQFieldElem, v::Vector{QQFieldElem}) = x .* v
*(v::Vector{QQFieldElem}, x::QQFieldElem) = v .* x

//(v::Vector{QQFieldElem}, x::ZZRingElem) = v .// x
/(v::Vector{QQFieldElem}, x::ZZRingElem) = v ./ x
*(x::ZZRingElem, v::Vector{QQFieldElem}) = x .* v
*(v::Vector{QQFieldElem}, x::ZZRingElem) = v .* x
YueRen marked this conversation as resolved.
Show resolved Hide resolved


###############################################################################
#
Expand Down
6 changes: 6 additions & 0 deletions test/flint/fmpq-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,14 @@ end

@testset "QQFieldElem.vector_arithmetics" begin
@test QQFieldElem[1, 2, 3] // QQFieldElem(2) == QQFieldElem[1//2, 1, 3//2]
@test QQFieldElem[1, 2, 3] / QQFieldElem(2) == QQFieldElem[1//2, 1, 3//2]
@test QQFieldElem(2) * QQFieldElem[1, 2, 3] == QQFieldElem[2, 4, 6]
@test QQFieldElem[1, 2, 3] * QQFieldElem(2) == QQFieldElem[2, 4, 6]

@test QQFieldElem[1, 2, 3] // ZZRingElem(2) == QQFieldElem[1//2, 1, 3//2]
@test QQFieldElem[1, 2, 3] / ZZRingElem(2) == QQFieldElem[1//2, 1, 3//2]
@test ZZRingElem(2) * QQFieldElem[1, 2, 3] == QQFieldElem[2, 4, 6]
@test QQFieldElem[1, 2, 3] * ZZRingElem(2) == QQFieldElem[2, 4, 6]
end

@testset "QQFieldElem.manipulation" begin
Expand Down
Loading