[sage-support] Re: Vector from polynomial coefficients -- length

2009-02-13 Thread Craig Citro

> Instead of using vectors, you should just use the indexing on the
> polynomials to extract the coefficients you want:
>
> sage: matrix([[p[i] for i in range(3)] for p in [x^10%p1, x^11%p1, x^12%p1]])
> [1 0 1]
> [1 1 1]
> [1 1 0]
>

There's also the "padded_list" method, used exactly for getting
vectors of a specific length:

sage: R. = GF(2)[]
sage: f = x^2-3
sage: f.list()
[1, 0, 1]

sage: f.padded_list(5)
[1, 0, 1, 0, 0]

sage: p2 = x^5-4*x^2-1

sage: [ ((x^i)%p2).list() for i in range(8,12) ]
[[0, 0, 0, 1], [0, 0, 0, 0, 1], [1], [0, 1]]

sage: [ ((x^i)%p2).padded_list(p2.degree()) for i in range(8,12) ]
[[0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [1, 0, 0, 0, 0], [0, 1, 0, 0, 0]]

-cc

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Vector from polynomial coefficients -- length

2009-02-13 Thread Mike Hansen

Hello,

On Fri, Feb 13, 2009 at 2:36 AM, acd  wrote:
> When I try the following in Sage, it fails because leading zeros in
> the vector are skipped:

The leading zeros aren't skipped -- the trailing ones are.  For example,

sage: R. = GF(2)[]
sage: list(x^4+x^3+1)
[1, 0, 0, 1, 1]

The i^th entry in the list corresponds to the coefficient of x^i.

Instead of using vectors, you should just use the indexing on the
polynomials to extract the coefficients you want:

sage: matrix([[p[i] for i in range(3)] for p in [x^10%p1, x^11%p1, x^12%p1]])
[1 0 1]
[1 1 1]
[1 1 0]

--Mike

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---