Skip to content

Commit 250048d

Browse files
authored
Merge pull request #67 from JuliaAlgebra/bl/round
Add arguments to round
2 parents 6808112 + 3e8cabb commit 250048d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/polynomial.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ function mapcoefficientsnz(f::Function, p::AbstractPolynomialLike)
368368
end
369369
mapcoefficientsnz(f::Function, t::AbstractTermLike) = f(coefficient(t)) * monomial(t)
370370

371-
Base.round(t::AbstractTermLike) = round(coefficient(t)) * monomial(t)
372-
function Base.round(p::AbstractPolynomialLike)
371+
Base.round(t::AbstractTermLike, args...) = round(coefficient(t), args...) * monomial(t)
372+
function Base.round(p::AbstractPolynomialLike, args...)
373373
# round(0.1) is zero so we cannot use SortedUniqState
374-
polynomial(round.(terms(p)), SortedState())
374+
polynomial(round.(terms(p), args...), SortedState())
375375
end

test/polynomial.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117

118118
@test (@inferred round(2.6x + 1.001x^2)) == 3x + 1x^2
119119
@test (@inferred round(3.1x*y)) == 3x*y
120+
@test (@inferred round(2.613x + 1.1051x^2, 2)) 2.61x + 1.11x^2
121+
@test (@inferred round(3.145x*y, 1)) 3.1x*y
120122

121123
@testset "Graded Lex Order" begin
122124
Mod.@polyvar x y z

0 commit comments

Comments
 (0)