JuliaMath / Polynomials.jl

Polynomial manipulations in Julia
http://juliamath.github.io/Polynomials.jl/
Other
303 stars 74 forks source link

Question: old type `Poly{T}` -- replacement? #585

Open B-LIE opened 4 days ago

B-LIE commented 4 days ago

I just dug up some old code from 2020, or so, where I used the Polynomials.jl package.

One of my constructs doesn't work any more,

#
# Routine to find the vector of column degrees
#
function col_deg(M::Matrix{Poly{T}}) where T<:Number
    return maximum(length.(coeffs.(M)),dims=1)[:].-1
end

Seems like Poly{T} doesn't exist any more.

jverzani commented 4 days ago

There is a Compat module that should make that available

On Wed, Oct 2, 2024 at 11:55 AM Bernt Lie @.***> wrote:

I just dug up some old code from 2020, or so, where I used the Polynomials.jl package.

One of my constructs doesn't work any more,

Routine to find the vector of column degrees#function col_deg(M::Matrix{Poly{T}}) where T<:Number

return maximum(length.(coeffs.(M)),dims=1)[:].-1end

Seems like Poly{T} doesn't exist any more.

  • Has Poly{T} been replaced by another type?

— Reply to this email directly, view it on GitHub https://github.com/JuliaMath/Polynomials.jl/issues/585, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADG6TEZAW3MI2BN7GPJFOTZZO7K5AVCNFSM6AAAAABPHKMW72VHI2DSMVQWIX3LMV43ASLTON2WKOZSGU3DCMJTG44DMNA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

B-LIE commented 4 days ago

Thanks! That worked right away.

B-LIE commented 3 days ago

Hm... I used a coeffs function, but that doesn't seem to work with the Poly type any more. So I'm switching to the modern version (Polynomial type).

There used to be a poly function, but I cannot find that any more. Any clue as to what it did/if there is a modern version?

jverzani commented 3 days ago

Maybe it isn’t exported? Does Polynomials.coeffs work?

John Verzani Chair, University Faculty Senate https://www1.cuny.edu/sites/cunyufs/

and Department of Mathematics College of Staten Island, CUNY

On Thu, Oct 3, 2024 at 12:15 PM Bernt Lie @.***> wrote:

Hm... I used a coeffs function, but that doesn't seem to work with the Poly type any more. So I'm switching to the modern version (Polynomial type).

There used to be a poly function, but I cannot find that any more. Any clue as to what it did/if there is a modern version?

— Reply to this email directly, view it on GitHub https://github.com/JuliaMath/Polynomials.jl/issues/585#issuecomment-2391036914, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADG6TGSQWTK5FBG7PBTSH3ZZUKMZAVCNFSM6AAAAABPHKMW72VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJRGAZTMOJRGQ . You are receiving this because you commented.Message ID: @.***>

B-LIE commented 3 days ago

Yes, Polynomials.coeffs works. And coeffs is exported, so if I just do using Polynomials, I can do coeffs.

I've rewritten the code to use Polynomials directly, and avoided using the compat mode.

I then found that I had used both Poly and poly in the code. I seem to recall that these do the same thing, and the same as constructor Polynomial in the new system.

B-LIE commented 3 days ago

A silly question, unrelated to Polynomials.jl... I have defined a struct named MFD (matrix fraction description) where I define, e.g., a system as:

sys = MFD(N, D, div)

where N is a numerator matrix with polynomial elements and D is a denominator matrix with polynomial elements, and div is either :right or :left depending on whether I use right division or left division.

I then also defined some "functions" that can operate on sys, using syntax:

function (p::MFD)(x::T) where T <: Union{Float16,Float32,Float64,BigFloat,Complex}
    return ...
end

This way, I could, e.g., write sys(0.3) and have the system evaluated for polynomial variable (default: :x) set equal to 0.3.

I can't seem to find this syntax in the Julia documentation... way back, someone referred to this as a functor , although I don't know whether it is a functor in the mathematical sense. Nowadays, there is a package "Functor.jl" which probably does something very different.

Problem is: do you know how to find the documentation of this syntax?

B-LIE commented 3 days ago

OK ... I guess I found some ideas at https://discourse.julialang.org/t/best-practice-for-storing-functions-in-a-struct/9654/11 .