diff --git a/Project.toml b/Project.toml index 38791059..e2726fe6 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,7 @@ name = "Polynomials" uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" license = "MIT" author = "JuliaMath" -version = "2.0.0" +version = "2.0.1" [deps] Intervals = "d8418881-c3e1-53bb-8760-2df7ec849ed5" diff --git a/docs/src/extending.md b/docs/src/extending.md index 34cfb9c3..ac7fd581 100644 --- a/docs/src/extending.md +++ b/docs/src/extending.md @@ -35,7 +35,7 @@ Check out both the [`Polynomial`](@ref) and [`ChebyshevT`](@ref) for examples of ## Example The following shows a minimal example where the polynomial aliases the vector defining the coefficients. -The constructor ensures that there are no trailing zeros. The `@register` call ensures a common interface. This example subtypes `StandardBasisPolynomial`, not `AbstractPolynomial`, and consequently inherits the methods above that otherwise would have been required. For other bases, more methods may be necessary to define (again, refer to [`ChebyshevT`](@ref) for an example). +The constructor ensures that there are no trailing zeros. The `@register` call ensures a common interface. This example subtypes `StandardBasisPolynomial`, not `AbstractPolynomial`, and consequently inherits the methods above that otherwise would have been required. For other bases, more methods may be necessary to define (again, refer to [`ChebyshevT`](@ref) for an example). ```jldoctest AliasPolynomial julia> using Polynomials diff --git a/src/abstract.jl b/src/abstract.jl index 5bfed88e..1a91370a 100644 --- a/src/abstract.jl +++ b/src/abstract.jl @@ -56,9 +56,9 @@ macro register(name) $poly{eltype(cs), Symbol(var)}(cs) end $poly{T,X}(n::S) where {T, X, S<:Number} = - n * one($poly{T, X}) + T(n) * one($poly{T, X}) $poly{T}(n::S, var::SymbolLike = :x) where {T, S<:Number} = - n * one($poly{T, Symbol(var)}) + T(n) * one($poly{T, Symbol(var)}) $poly(n::S, var::SymbolLike = :x) where {S <: Number} = n * one($poly{S, Symbol(var)}) $poly{T}(var::SymbolLike=:x) where {T} = variable($poly{T, Symbol(var)}) $poly(var::SymbolLike=:x) = variable($poly, Symbol(var)) @@ -85,8 +85,8 @@ macro registerN(name, params...) $poly{$(αs...)}(coeffs::AbstractVector{T}, var::SymbolLike=:x) where {$(αs...),T} = $poly{$(αs...),T,Symbol(var)}(coeffs) - $poly{$(αs...),T,X}(n::Number) where {$(αs...),T,X} = n*one($poly{$(αs...),T,X}) - $poly{$(αs...),T}(n::Number, var::SymbolLike = :x) where {$(αs...),T} = n*one($poly{$(αs...),T,Symbol(var)}) + $poly{$(αs...),T,X}(n::Number) where {$(αs...),T,X} = T(n)*one($poly{$(αs...),T,X}) + $poly{$(αs...),T}(n::Number, var::SymbolLike = :x) where {$(αs...),T} = T(n)*one($poly{$(αs...),T,Symbol(var)}) $poly{$(αs...)}(n::S, var::SymbolLike = :x) where {$(αs...), S<:Number} = n*one($poly{$(αs...),S,Symbol(var)}) $poly{$(αs...),T}(var::SymbolLike=:x) where {$(αs...), T} = variable($poly{$(αs...),T,Symbol(var)}) diff --git a/src/polynomials/ngcd.jl b/src/polynomials/ngcd.jl index 80a07600..d7bc7577 100644 --- a/src/polynomials/ngcd.jl +++ b/src/polynomials/ngcd.jl @@ -10,10 +10,10 @@ In the case `degree(p) ≫ degree(q)`, a heuristic is employed to first call on function ngcd(p::P, q::Q, args...;kwargs...) where {T, S, P<:StandardBasisPolynomial{T}, Q <: StandardBasisPolynomial{S}} degree(p) < 0 && return (u=q, v=p, w=one(q), θ=NaN, κ=NaN) - degree(p) == 0 && return (u=one(q), v=p, w=zero(q), θ=NaN, κ=NaN) + degree(p) == 0 && return (u=one(q), v=p, w=q, θ=NaN, κ=NaN) degree(q) < 0 && return (u=one(q), v=p, w=zero(q), θ=NaN, κ=NaN) degree(q) == 0 && return (u=one(p), v=p, w=q, θ=NaN, κ=NaN) - assert_same_variable(p,q) + assert_same_variable(p,q) p′,q′ = promote(p,q) @@ -264,8 +264,8 @@ end # return guess at smallest singular value and right sinuglar value, x # for an upper triangular matrix, V function smallest_singular_value(V::AbstractArray{T,2}, - atol=eps(T), - rtol=zero(T)) where {T} + atol=eps(real(T)), + rtol=zero(real(T))) where {T} R = UpperTriangular(V) k = size(R)[1]/2 diff --git a/test/StandardBasis.jl b/test/StandardBasis.jl index df736aac..93eb57f5 100644 --- a/test/StandardBasis.jl +++ b/test/StandardBasis.jl @@ -42,6 +42,12 @@ isimmutable(::Type{<:ImmutablePolynomial}) = true P == Polynomial && @test typeof(p).parameters[1] == eltype(coeff) @test eltype(p) == eltype(coeff) @test all([-200, -0.3, 1, 48.2] .∈ domain(p)) + + ## issue #316 + @test_throws InexactError P{Int,:x}([1+im, 1]) + @test_throws InexactError P{Int}([1+im, 1], :x) + @test_throws InexactError P{Int,:x}(1+im) + @test_throws InexactError P{Int}(1+im) end end