Hi Anastasia,
On 2017-03-15, Anastasia Theodouli wrote:
> I would like to get in a list *ONLY* the coefficients of the following
> monomials of P (including zero coefficients in correct order)
>
> (x0^2, x0*x1, x1^2, x0*x2, x1*x2, x2^2, x0, x1, x2, 1)
If you only
As I posted at
http://stackoverflow.com/questions/42812634/multivariate-polynomial-coefficients-including-zeros,
you could use lcm(f.monomials()) to get the least common multiple of the
monomials in f, and then plug that into P.monomial_all_divisors(lcm(...))
to get all monomials which
I also tried the following
P1 = PolynomialRing(ZZ,'x',3)
f=x0^2+2*x0*x1+x1^2+2*x0*x2+x1*x2+2*x2^2+x0+2*x1+x2+2
coeffs=[]
for mon in f.monomials():
coeffs.append(f.monomial_coefficient(mon))
coeffs
it returns the correct list, i.e.
[1, 2, 1, 2, 1, 2, 1, 2, 1, 2]
but if I omit a
Thank you very much Vincent! The code below is very close to what I want to
achieve.
There is a detail I haven't mentioned before.
If I have n=3, which means that P is
P: Multivariate Polynomial Ring in x0, x1, x2 over Integer Ring
I would like to get in a list *ONLY* the coefficients of
Hello,
I think the following code is basically what you want
n = 5
P = PolynomialRing(ZZ, 'x', n)
p = P.random_element(degree=3)
from itertools import product
coeffs = []
for i in product(range(3), repeat=n):
coeffs.append(p.coefficient(dict(zip(P.gens(), i
print(coeffs)
Vincent
On
Dears,
I would like to get the coefficients of a *multivariate* polynomial*
including the zero coefficients (in their correct position*s). I have found
a similar answer as regards a polynomial f of two variables x,y
P. = PolynomialRing(ZZ, 2, order='lex')
f=3*x^2*y^2+x*y+3
Then using
>
> OMG , sorry , that's my bad
>
I used this Jupyter as if it was the interactive shell of sage, I realised
now there's a terminal hiding somewhere there. I am actually much more
comfortable with the terminal.
Anyway, it was good to point that Galois fields less than 2^16 doesn't work