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

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

Open
B-LIE opened this issue Oct 2, 2024 · 7 comments
Open

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

B-LIE opened this issue Oct 2, 2024 · 7 comments

Comments

@B-LIE
Copy link

B-LIE commented Oct 2, 2024

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.

  • Has Poly{T} been replaced by another type?
@jverzani
Copy link
Member

jverzani commented Oct 2, 2024 via email

@B-LIE
Copy link
Author

B-LIE commented Oct 2, 2024

Thanks! That worked right away.

@B-LIE
Copy link
Author

B-LIE commented Oct 3, 2024

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
Copy link
Member

jverzani commented Oct 3, 2024 via email

@B-LIE
Copy link
Author

B-LIE commented Oct 3, 2024

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
Copy link
Author

B-LIE commented Oct 3, 2024

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
Copy link
Author

B-LIE commented Oct 3, 2024

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

No branches or pull requests

2 participants