Skip to content

Commit

Permalink
Merge pull request #111 from jverzani/nodot
Browse files Browse the repository at this point in the history
remove misuse of dot, v0.6 clean up; closes #110
  • Loading branch information
jverzani committed Mar 20, 2017
2 parents 0da3d97 + e8428a5 commit 7dc8b85
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/Polynomials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export Pade, padeval
import Base: start, next, done, length, size, eltype
import Base: endof, getindex, setindex!, copy, zero, one, convert, norm, gcd
import Base: show, print, *, /, //, -, +, ==, isapprox, divrem, div, rem, eltype
import Base: promote_rule, truncate, chop, call, conj, transpose, dot, hash
import Base: promote_rule, truncate, chop, conj, transpose, dot, hash
import Base: isequal

typealias SymbolLike Union{AbstractString,Char,Symbol}
const SymbolLike = Union{AbstractString,Char,Symbol}

"""
Expand Down Expand Up @@ -260,9 +260,6 @@ one{T}(::Type{Poly{T}}) = Poly([one(T)])
## Overload arithmetic operators for polynomial operations between polynomials and scalars
*{T<:Number,S}(c::T, p::Poly{S}) = Poly(c * p.a, p.var)
*{T<:Number,S}(p::Poly{S}, c::T) = Poly(p.a * c, p.var)
dot{T<:Number,S}(p::Poly{S}, c::T) = p * c
dot{T<:Number,S}(c::T, p::Poly{S}) = c * p
dot(p1::Poly, p2::Poly) = p1 * p2
/(p::Poly, c::Number) = Poly(p.a / c, p.var)
-(p::Poly) = Poly(-p.a, p.var)
-{T<:Number}(p::Poly, c::T) = +(p, -c)
Expand Down
2 changes: 1 addition & 1 deletion src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ showone{S}(::Type{Poly{S}}) = false

"Show different operations depending on mimetype. `l-` is leading minus sign."
function showop(::MIME"text/plain", op)
d = Dict("*" => "", "+" => " + ", "-" => " - ", "l-" => "-")
d = Dict("*" => "*", "+" => " + ", "-" => " - ", "l-" => "-")
d[op]
end

Expand Down
10 changes: 5 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@ repr(p)

## changes to show
p = Poly([1,2,3,1]) # leading coefficient of 1
@test repr(p) == "Poly(1 + 2x + 3x^2 + x^3)"
@test repr(p) == "Poly(1 + 2*x + 3*x^2 + x^3)"
p = Poly([1.0, 2.0, 3.0, 1.0])
@test repr(p) == "Poly(1.0 + 2.0x + 3.0x^2 + 1.0x^3)"
@test repr(p) == "Poly(1.0 + 2.0*x + 3.0*x^2 + 1.0*x^3)"
p = Poly([1, im])
@test repr(p) == "Poly(1 + imx)"
@test repr(p) == "Poly(1 + im*x)"
p = Poly([1+im, 1-im, -1+im, -1 - im])# minus signs
@test repr(p) == "Poly((1 + 1im) + (1 - 1im)x - (1 - 1im)x^2 - (1 + 1im)x^3)"
@test repr(p) == "Poly((1 + 1im) + (1 - 1im)*x - (1 - 1im)*x^2 - (1 + 1im)*x^3)"
p = Poly([1.0, 0 + NaN*im, NaN, Inf, 0 - Inf*im]) # handle NaN or Inf appropriately
@test repr(p) == "Poly(1.0 + NaN⋅im⋅x + NaNx^2 + Infx^3 - Inf⋅im⋅x^4)"
@test repr(p) == "Poly(1.0 + NaN*im*x + NaN*x^2 + Inf*x^3 - Inf*im*x^4)"

p = Poly([1,2,3])
@test reprmime("text/latex", p) == "\$1 + 2\\cdot x + 3\\cdot x^{2}\$"
Expand Down

0 comments on commit 7dc8b85

Please sign in to comment.