sage: def ib(m, n): return sum(binomial(m*n-1, m*k)*cyclotomic_polynomial(m*(k+1)) for k in (0..n-1))
sage: ib(2,2)
3*x^2 + x + 4
sage: type(ib(2,2))
<type 'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint'>
sage: ib(2,2).list()
--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/de96a2b1-562c-4c09-9c38-07685a5bff4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I don't know what OmegaPolynomial is. However, if you replace it by cyclotomic_polynomial,it seems to work as expected, doesn't it?
sage: def ib(m, n): return sum(binomial(m*n-1, m*k)*cyclotomic_polynomial(m*(k+1)) for k in (0..n-1))
sage: ib(2,2)
3*x^2 + x + 4
sage: type(ib(2,2))
<type 'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint'>
sage: ib(2,2).list()
[4, 1, 3]
--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/4fc00a73-06c5-42be-9d5b-73bc53fcc683%40googlegroups.com.
AttributeError: 'int' object has no attribute 'list',Are you saying, the error message it spits out,
is misleading?
As I see it the problem is that the sum runs over (0..n-1).Thus for n = 0 it returns by convention the integer 0 for theempty sum (is this correct?) which of course has no list.But shouldn't it return the null polynomial in this case?And isn't the null polynomial represented by the empty list?
On Mon, Jun 17, 2019 at 5:18 AM Peter Luschny <peter....@gmail.com> wrote:def ib(m, n): return sum(binomial(m*n-1, m*k)*OmegaPolynomial(m,k) for k in (0..n-1))The terms "binomial(m*n-1, m*k)*OmegaPolynomial(m,k)" are of type<type 'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint'
But shouldn't it return the null polynomial in this case?And isn't the null polynomial represented by the empty list?
No, because sum has no way to know that you are expecting a polynomial.
How that? Look at the output above. Sage *knows* that the terms of the sumare polynomials. So it should return the zero of that ring, which is the null polynomial.
So, replacesum(binomial(m*n-1, m*k)*OmegaPolynomial(m,k) for k in (0..n-1))bysum((binomial(m*n-1, m*k)*OmegaPolynomial(m, k) for k in (0 .. n-1)), RR['x'].zero())
Am Di., 25. Juni 2019 um 10:49 Uhr 'luisfe' :| When n =0, k ranges from 0 to -1 so there is no k and the list constructed in ib(n,m)
| is just the empty list. Not an empty list of polynomials, just an empty list.
Well, then the way 'sum' is implemented is possibly improvable?
The type information for "binomial(m*n-1, m*k)*polynomial(m,k)"
is there, regardless of what the value of the integers m, n, and k is.