Skip to content

Commit

Permalink
Error on negative degree for monomials (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat authored Jul 12, 2023
1 parent 0a86994 commit afde1ef
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/monomial_vector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,15 @@ function MP.empty_monomial_vector(
return MonomialVector{V,M}()
end

# TODO replace by MP function
function _error_for_negative_degree(deg)
if deg < 0
throw(ArgumentError("The degree should be a nonnegative number but the provided degree `$deg` is negative."))
end
end

function fillZfordeg!(Z, n, deg, ::Type{Commutative}, filter::Function, ::Int)
_error_for_negative_degree(deg)
z = zeros(Int, n)
z[end] = deg
while true
Expand Down Expand Up @@ -159,6 +167,8 @@ function fillZfordeg!(
filter::Function,
maxdeg::Int,
)
_error_for_negative_degree(deg)
_error_for_negative_degree(maxdeg)
z = zeros(Int, maxdeg * n - maxdeg + 1)
start = length(Z) + 1
fillZrec!(Z, z, 1, n, deg, filter)
Expand Down

2 comments on commit afde1ef

@blegat
Copy link
Member Author

@blegat blegat commented on afde1ef Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error while trying to register: "Tag with name v0.5.1 already exists and points to a different commit"

Please sign in to comment.