Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmetic changes #72

Closed
wants to merge 1 commit into from
Closed

Cosmetic changes #72

wants to merge 1 commit into from

Conversation

aytekinar
Copy link
Contributor

@aytekinar aytekinar commented Oct 13, 2016

Some cosmetic changes are made related to:

  • Inner constructor. Now, Poly is defined only for SymbolLike
    objects, i.e., Char, AbstractString and Symbols,
  • Poly from variables. Since Poly("x") could have resulted in
    arguments related to what the default constructor should do (maybe a
    default behaviour of constructing a zero polynomial with the given
    variable is needed), I dropped my previous changes and extended
    e29591d to include SymbolLike objects for variable. Also, an outer
    constructor for Numbers is added for convenience,
  • Version checks. Dropped VERSION >= v"0.4" checks as the support
    for v"0.3" has already been dropped,
  • Base overloads. Moved all implicitly overloaded base functions to
    the import section on top.

I hope you would agree with the changes.

Cc: @jverzani, @Keno

Some cosmetic changes are made related to:

- **Inner constructor.** Now, `Poly` is defined only for `SymbolLike`
  objects, *i.e.*, `Char`, `AbstractString` and `Symbol`s,
- **Poly from variables.** Since `Poly("x")` could have resulted in
  arguments related to what the default constructor should do (maybe a
  default behaviour of constructing a `zero` polynomial with the given
  variable is needed), I dropped my previous changes and extended
  e29591d to include `SymbolLike` objects for `variable`. Also, an outer
  constructor for `Number`s is added for convenience,
  - [x] Fixes: #71.
- **Version checks.** Dropped `VERSION >= v"0.4"` checks as the support
  for v"0.3" has already been dropped,
- **Base overloads.** Moved all implicitly overloaded base functions to
  the import section on top.

I hope you would agree with the changes.
@aytekinar aytekinar changed the title Add support for x = Poly("x") Cosmetic changes Nov 30, 2016
@aytekinar aytekinar closed this Nov 30, 2016
@aytekinar aytekinar deleted the 71-poly-of-symbol branch November 30, 2016 12:23
end

@compat Poly{T<:Number}(a::Vector{T}, var::Union{AbstractString,Symbol,Char}=:x) = Poly{T}(a, var)
Poly(n::Number = zero(n), var::SymbolLike = :x) = Poly([n, zero(n)], var)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are degree 0 polynomials so common to construct that we need a new constructor?

copy(p::Poly) = Poly(copy(p.a), p.var)

zero{T}(p::Poly{T}) = Poly([zero(T)], p.var)
zero{T}(p::Poly{T}) = Poly(T[], p.var)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this rely on an implementation detail whereas the other doesn't? I don't quite understand the motivation here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants