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

Compatibility with OffsetMatrix? #293

Open
NAThompson opened this issue Apr 20, 2024 · 1 comment
Open

Compatibility with OffsetMatrix? #293

NAThompson opened this issue Apr 20, 2024 · 1 comment

Comments

@NAThompson
Copy link

In Polynomials.jl, we can use an OffsetArray to easily construct Laurent polynomials:

julia> using OffsetArrays
julia> using Polynomials
julia> o = OffsetArrays{Float64}(ones(5), -1:3)
julia> p = LaurentPolynomial(o)
LaurentPolynomial(1.0*x⁻¹ + 1.0 + 1.0*x + 1.0*+ 1.0*x³)

However, I cannot do the same for an OffsetMatrix with MultivariatePolynomials. Reading through the documentation, it appears the this library is more focuses on very sophisticated manipulations on polynomials that you could type out by hand, rather than large polynomials whose coefficients are stored in a matrix-so hopefully this issue is not too annoying. However, I felt like it might be natural to type something like the following, as well as increase compatibility with the univariate case:

julia> using OffsetArrays
julia> using MultivariatePolynomials
julia> o = OffsetMatrix{Float64}(ones(5), ones(5), -1:1, -1:1)
julia> p = MultivariateLaurentPolynomial(o, x, y)
MultivariateLaurentPolynomial(1.0*x⁻¹ y⁻¹ + 1.0x⁻¹ + 1.0*y⁻¹ + 1.0 + 1.0*x + 1.0*y + 1.0*xy)
@blegat
Copy link
Member

blegat commented Apr 23, 2024

Negative exponents is currently not supported in this package, e.g., it will make printing fail but it's probably not too hard to add support for it. Then you could easily do sum(o[i, j] * x[i] * y[j] for i in axes(o, 1), j in axes(o, 2))

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