Skip to content
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
2 changes: 2 additions & 0 deletions src/generic/UnivPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ function deepcopy_internal(p::UnivPoly{T}, dict::IdDict) where {T}
return UnivPoly{T}(deepcopy_internal(data(p), dict), parent(p))
end

Base.copy(f::UnivPoly{T}) where {T} = UnivPoly{T}(copy(data(f)), parent(f))

###############################################################################
#
# Multivariate coefficients
Expand Down
12 changes: 12 additions & 0 deletions test/generic/UnivPoly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1144,26 +1144,38 @@ end
f1 = add!(f1, g, h)

@test f1 == g + h
@test f == 3x^3 + 2x^2 + x + 4

f2 = deepcopy(f)
f2 = add!(f2, g)

@test f2 == f + g
@test f == 3x^3 + 2x^2 + x + 4

f3 = deepcopy(f)
f3 = mul!(f3, g, h)

@test f3 == g*h
@test f == 3x^3 + 2x^2 + x + 4

f4 = deepcopy(f)
f4 = addmul!(f4, g, h)

@test f4 == f + g*h
@test f == 3x^3 + 2x^2 + x + 4

f5 = deepcopy(f)
f5 = zero!(f5)

@test f5 == 0
@test f == 3x^3 + 2x^2 + x + 4

# also verify `copy` works as intended
f6 = copy(f)
f6 = zero!(f6)

@test f6 == 0
@test f == 3x^3 + 2x^2 + x + 4
end
end

Expand Down