Skip to content

Commit 7743f23

Browse files
authored
feat: add coeff for multivariate laurent polynomials (Nemocas#2218)
1 parent 61b6d9d commit 7743f23

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/generic/LaurentMPoly.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ function constant_coefficient(a::LaurentMPolyWrap)
428428
return coeff(a.mpoly, e)
429429
end
430430

431+
function coeff(a::LaurentMPolyWrap, e::Vector{Int})
432+
return coeff(a.mpoly, e - a.mindegs)
433+
end
434+
431435
#### exponent vectors
432436

433437
function leading_exponent_vector(a::LaurentMPolyWrap)

test/generic/LaurentMPoly-test.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ end
8989
@test a == sum(coefficients(a) .* monomials(a))
9090
@test a == L(collect(coefficients(a)), collect(exponent_vectors(a)))
9191
@test iszero((@inferred constant_coefficient(a)))
92+
@test coeff(a, [-2, 1]) == 2
93+
@test coeff(a, [1, -3]) == 3
94+
@test coeff(a, [1, 1]) == 0
9295

9396
b = MPolyBuildCtx(L)
9497
for (c, e) in zip(coefficients(a), exponent_vectors(a))

0 commit comments

Comments
 (0)