1 | initial version |
Let's see the doc :
* "sparse" -- bool (default: False), whether or not elements are
sparse
As far as I understand it, a sparse polynomial stores only the non-zero coefficients (less storage, more computing), whereas a non-sparse polynomial stores all its coefficients (more storage, less computing). That can be critical when you have to work with polynomials having few coefficients of very high order...
Those polynomials are compatible (and sparsity seems to won over non-sparsity) :
sage: K=GF(17)
sage: R.<z>=PolynomialRing(K,sparse=False)
sage: S.<z>=PolynomialRing(K,sparse=True)
sage: r1=z^17-3*z^13+1
sage: s1=S(r1)
sage: t1=r1-2*s1
sage: t1
16*z^17 + 3*z^13 + 16
sage: t1.parent()
Sparse Univariate Polynomial Ring in z over Finite Field of size 17
2 | No.2 Revision |
Let's see the doc :
* "sparse" -- bool (default: False), whether or not elements are
sparse
As far as I understand it, a sparse polynomial stores only the non-zero coefficients (less storage, more computing), whereas a non-sparse polynomial stores all its coefficients (more storage, less computing). That can be critical when you have to work with polynomials having few coefficients of very high order...
Those polynomials are compatible (and sparsity seems to won win over non-sparsity) :
sage: K=GF(17)
sage: R.<z>=PolynomialRing(K,sparse=False)
sage: S.<z>=PolynomialRing(K,sparse=True)
sage: r1=z^17-3*z^13+1
sage: s1=S(r1)
sage: t1=r1-2*s1
sage: t1
16*z^17 + 3*z^13 + 16
sage: t1.parent()
Sparse Univariate Polynomial Ring in z over Finite Field of size 17
3 | No.3 Revision |
Let's see the doc :
* "sparse" -- bool (default: False), whether or not elements are
sparse
As far as I understand it, a sparse polynomial stores only the non-zero coefficients (less storage, more computing), whereas a non-sparse polynomial stores all its coefficients (more storage, less computing). That can be critical when you have to work with polynomials having few coefficients of very high order...
Those polynomials are compatible (and sparsity seems :
sage: K=GF(17)
sage: R.<z>=PolynomialRing(K,sparse=False)
sage: r1=z^17-z^13+1
sage: r1.parent()
Univariate Polynomial Ring in z over Finite Field of size 17
sage: S.<z>=PolynomialRing(K,sparse=True)
sage: r1.parent()
Univariate Polynomial Ring in z over Finite Field of size 17
sage: s1=S(copy(r1))
sage: s1.parent()
Sparse Univariate Polynomial Ring in z over Finite Field of size 17
The use of a copy of r1 allows to win over non-sparsity) :
sage: K=GF(17)
sage: R.<z>=PolynomialRing(K,sparse=False)
sage: S.<z>=PolynomialRing(K,sparse=True)
sage: r1=z^17-3*z^13+1
sage: s1=S(r1)
keep r1's parent set : sage: r1.parent()
Univariate Polynomial Ring in z over Finite Field of size 17
One can compute on these two "compatible" sets :
sage: t1=r1-2*s1
sage: t1
16*z^17 + 3*z^13 z^13 + 16
sage: t1.parent()
Univariate Polynomial Ring in z over Finite Field of size 17
sage: r1.parent()
Univariate Polynomial Ring in z over Finite Field of size 17
sage: s1.parent()
Sparse Univariate Polynomial Ring in z over Finite Field of size 17
BTW, the use of copy
does not seem necessary (but ISTR that I've been hoisted by this...) :
sage: s2=S(r1)
sage: r1.parent()
Univariate Polynomial Ring in z over Finite Field of size 17
sage: s2.parent()
Sparse Univariate Polynomial Ring in z over Finite Field of size 17
HTH,