Skip to content

Commit 6c82aaf

Browse files
authored
add generated norm function for ImmutablePolynomial (#266)
* add generated norm function for ImmutablePolynomial * bump, cleanup test logic
1 parent 33a45ae commit 6c82aaf

File tree

5 files changed

+208
-169
lines changed

5 files changed

+208
-169
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "Polynomials"
22
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
33
license = "MIT"
44
author = "JuliaMath"
5-
version = "1.1.7"
5+
version = "1.1.8"
66

77
[deps]
88
Intervals = "d8418881-c3e1-53bb-8760-2df7ec849ed5"

src/abstract.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ macro register(name)
5252
$poly{T}(coeffs, Symbol(var))
5353
$poly{T}(x::AbstractVector{S}, var::SymbolLike = :x) where {T,S<:Number} =
5454
$poly(T.(x), Symbol(var))
55+
function $poly(coeffs::G, var::SymbolLike=:x) where {G}
56+
!Base.isiterable(G) && throw(ArgumentError("coeffs is not iterable"))
57+
$poly(collect(coeffs), var)
58+
end
5559
$poly{T}(n::S, var::SymbolLike = :x) where {T, S<:Number} =
5660
n * one($poly{T}, Symbol(var))
5761
$poly(n::S, var::SymbolLike = :x) where {S <: Number} = n * one($poly{S}, Symbol(var))

src/common.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ Calculates the p-norm of the polynomial's coefficients
266266
"""
267267
function LinearAlgebra.norm(q::AbstractPolynomial, p::Real = 2)
268268
vs = values(q)
269-
isempty(vs) && return zero(q[0])
270-
return norm(vs, p)
269+
return norm(vs, p) # if vs=() must be handled in special type
271270
end
272271

273272
"""

0 commit comments

Comments
 (0)