Skip to content

Commit d5c371c

Browse files
committed
Add docs to isreal & real
1 parent f127109 commit d5c371c

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/abstract.jl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,27 @@ abstract type AbstractPolynomial{T} end
1818
(P::Type{<:AbstractPolynomial}) = constructorof(P)
1919

2020
# See discussions in https://github.com/JuliaMath/Polynomials.jl/issues/258
21-
is_(fn, p::AbstractPolynomial) = all(fn, coeffs(p))
22-
as_(fn, p::P) where {P<:AbstractPolynomial} = (P)(fn.(coeffs(p)), p.var)
21+
is_(fn, p::AbstractPolynomial) = all(fn, coeffs(p)) # Do not export
22+
as_(fn, p::P) where {P<:AbstractPolynomial} = (P)(fn.(coeffs(p)), p.var) # Do not export
2323

24+
"""
25+
isreal(p::AbstractPolynomial)
26+
27+
Determine whether a polynomial is a real polynomial, i.e., having only real numbers as coefficients.
28+
29+
See also: [`real`](@ref)
30+
"""
2431
Base.isreal(p::AbstractPolynomial) = is_(isreal, p)
32+
"""
33+
real(p::AbstractPolynomial)
34+
35+
Construct a real polynomial from the real parts of the coefficients of `p`.
36+
37+
See also: [`isreal`](@ref)
38+
39+
!!! note
40+
This could cause losing terms in `p`. This method is usually called on polynomials like `p = Polynomial([1, 2 + 0im, 3.0, 4.0 + 0.0im])` where you want to chop the imaginary parts of the coefficients of `p`.
41+
"""
2542
Base.real(p::AbstractPolynomial) = as_(real, p)
2643

2744
"""

0 commit comments

Comments
 (0)