BudanTables.jl

I implemented a package for plotting the Budan’s table of a polynomial (Budan-Fourier theorem uses it for root counting, see Improved Budan-Fourier Count for Root Finding).

https://github.com/LauraBMo/BudanTables.jl

By default, polynomials and polynomials operations are represented using Polynomials.jl, but the user may use other implementations.

Comments are highly welcome!
Actually, I have two questions:

1.- Is there a more generic way to use Polynomials.jl?
For example, (it is not its intended use, but) with Requires.jl I could use Polynomials.jl only when Polynomials.jl is loaded by the user.
But how do I implement functions depending on derivative or degree outside of the @require Polynomials="..." block?

An option could be to adapt the trick

const _ROOTS = Ref{Function}(roots)

function set_getting_roots(f)
    _ROOTS[] = f
end

to something like

  const _ROOTS = Ref{Function}()
  const _DERIVATIVE = Ref{Function}()
  const _DEGREE = Ref{Function}()

  function set_getting_roots(f)
      _ROOTS[] = f
  end
  # add equivalent functions for derivative and degree

  function __init__()
      @require Polynomials="..." begin
            set_getting_roots(Polynomials.roots)
           # add equivalents for derivative and degree 
      end
  end

But it sounds too demanding for users who don’t want to use Polynomials.jl. As they have to define/load the functions roots, derivative, degree and then pass them to ButanTables.jl via the functions set_getting_roots, set_getting_derivative

2.- It is my first time using RecipesBase.jl for Plots.jl, does it look good?
I feel the way I implemented the legend is way too hacky.

Many thanks!

3 Likes

I think question 1 falls into Optionnal dependencies and allow options for packages.

I end up using Polynomials.jl to represent polynomials and, via Requires.jl, the user can choose between Polynomials.roots and PolynoamialRoots.roots. It is also possible not to use Polynomials.jl but some redundant code will be loaded anyways.