Skip to content

Define monomial constructor #328

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/gcd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,8 @@ function deflation(p::AbstractPolynomialLike)
shift_defl = shift_deflation.(p, variables(p))
shift = getindex.(shift_defl, 1)
defl = getindex.(shift_defl, 2)
s = prod(
variables(p) .^ shift;
init = constant_monomial(p),
)::monomial_type(p)
d = prod(
variables(p) .^ defl;
init = constant_monomial(p),
)::monomial_type(p)
s = monomial(variables(p), shift)
d = monomial(variables(p), defl)
return s, d
end

Expand Down
11 changes: 11 additions & 0 deletions src/term.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ Returns the monomial of the term `t`.
### Examples

Calling `monomial` on ``4x^2y`` should return ``x^2y``.

monomial(variables, exponents)

Returns the monomial corresponding to `prod(variables .^ exponents)`

### Examples

In order to create `x^2 * y`,

* with DynamicPolynomials, use `monomial([x, y], [2, 1])`,
* with TypedPolynomials, use `monomial((x, y), (2, 1))`.
"""
function monomial end
monomial(t::AbstractTerm) = t.monomial # by convention, the field should be `monomial`.
Expand Down
Loading