Skip to content

Commit 7b8265f

Browse files
committed
Added docstrings
1 parent ead527c commit 7b8265f

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/Polynomials.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,11 @@ polyder(a::AbstractArray{Poly{T}}, order::Int = 1) where {T} = map(p->polyder(p,
580580

581581
# compute the roots of a polynomial
582582
"""
583-
roots(p::Poly)
583+
roots(p::Poly; kwargs...)
584584
585585
Return the roots (zeros) of `p`, with multiplicity. The number of roots
586586
returned is equal to the order of `p`. The returned roots may be real or
587-
complex.
587+
complex. Keyword arguments `kwargs` are sent to the `eigvals` call.
588588
589589
# Examples
590590
@@ -610,6 +610,17 @@ julia> roots(poly([1,2,3,4]))
610610
3.0
611611
2.0
612612
1.0
613+
614+
julia> roots(Poly([1, 0, -1]), scale=false, permute=false)
615+
2-element Array{Float64,1}:
616+
-1.0
617+
1.0
618+
619+
# In Julia > 1.2
620+
julia> roots(Poly([1, 0, -1]), sortby = t -> -real(t))
621+
2-element Array{Float64,1}:
622+
1.0
623+
-1.0
613624
```
614625
"""
615626
function roots(p::Poly{T}; kwargs...) where {T}
@@ -639,7 +650,7 @@ function roots(p::Poly{T}; kwargs...) where {T}
639650
r[1:n] = D
640651
return r
641652
end
642-
roots(p::Poly{Rational{T}}) where {T} = roots(convert(Poly{promote_type(T, Float64)}, p))
653+
roots(p::Poly{Rational{T}}; kwargs...) where {T} = roots(convert(Poly{promote_type(T, Float64)}, p); kwargs...)
643654

644655
## compute gcd of two polynomials
645656
"""

src/show.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ end
7070
###
7171

7272
"""
73-
printpoly(io::IO, p::Poly, mimetype = MIME"text/plain"(); descending_powers=false, offset::Int=0)
73+
printpoly(io::IO, p::Poly, mimetype = MIME"text/plain"(); descending_powers=false, offset::Int=0, var=p.var)
7474
7575
Print a human-readable representation of the polynomial `p` to `io`. The MIME
7676
types "text/plain" (default), "text/latex", and "text/html" are supported. By
7777
default, the terms are in order of ascending powers, matching the order in
7878
`coeffs(p)`; specifying `descending_powers=true` reverses the order.
7979
`offset` allows for an integer number to be added to the exponent, just for printing.
80+
`var` allows for overriding the variable used for printing.
8081
8182
# Examples
8283
```jldoctest
@@ -88,6 +89,8 @@ julia> printpoly(stdout, Poly([2, 3, 1], :z), descending_powers=true, offset=-2)
8889
1 + 3*z^-1 + 2*z^-2
8990
julia> printpoly(stdout, Poly([-1, 0, 1], :z), offset=-1, descending_powers=true)
9091
z - z^-1
92+
julia> printpoly(stdout, Poly([-1, 0, 1], :z), offset=-1, descending_powers=true, var=:x)
93+
x - x^-1
9194
```
9295
"""
9396
function printpoly(io::IO, p::Poly{T}, mimetype=MIME"text/plain"(); descending_powers=false, offset::Int=0, var=p.var) where {T}

0 commit comments

Comments
 (0)