converting linear map to matrix representation

asked 8 years ago

gelatine1 gravatar image

I have a linear map α from FpnFpn, where we see Fpn as a vector space over Fp with a Vi as base elements. I want to create the matrix representation for α. For that I have to calculate α(Vi) and then write it in the basis Vi to get my values for the matrix. How exactly do I do the last in sage ? For eg. a polynomial ring it's easy because the elements are already written according to its base but in general thats not the case...

Preview: (hide)

Comments

As you said for polynomials, it depends on the way your elements are represented. Could you please provide an example for α and Vi (the one you are dealing with, with the code to produce them) ?

tmonteil gravatar imagetmonteil ( 8 years ago )

p=5
F.<c>=GF(p^p,modulus=x^p-x-1)
V=[c^i for i in [0..p-1]]
s=c^6+c^3+c^2+1

Now I want to get the coeffecients of s represented to the base V[i], how do i do that

gelatine1 gravatar imagegelatine1 ( 8 years ago )

(You can mark the code as code in the comment window, just mark it and click in the edit menu that icon with two rows, 101, and 010. This will indent everything by 4 spaces in the window comment, the markdown parser will recognize it and give syntax highlight...)

dan_fulea gravatar imagedan_fulea ( 8 years ago )

The following dialog with the sage interpreter (linux console) gives some ideas to proceed:

sage: p = 5
sage: q = p^p
sage: f = GF(p)
sage: R.<x> = f[]
sage: F.<c> = GF( q, modulus=x^p-x-1 )
sage: s = c^6+c^3+c^2+1
sage: s
c^3 + 2*c^2 + c + 1
sage: pol = R(s)    # the lift of s in R
sage: pol
x^3 + 2*x^2 + x + 1
sage: R( c^2+3 ).coefficients() # trap
[3, 1]
sage: R( c^2+3 ).coefficients( sparse=0 )
[3, 0, 1]

We can lift to Z. (No sense, criptic. Apply then f.)

sage: ZZ( s.integer_representation() ).digits(base=p)
[1, 1, 2, 1]

Of course, the list is to short. So:

sage: L = R(s).coefficients( sparse=0 )
sage: L
[1, 1, 2, 1]
sage: L += (p-len(L)) * [ f(0), ]
sage: L
[1, 1, 2, 1, 0]
dan_fulea gravatar imagedan_fulea ( 8 years ago )

With the above notations:

sage: def coeffs( s ):                                            
    L = R(s).coefficients( sparse=False )
    L += (p-len(L)) * [ f(0), ]
    return L
....: 
sage: M = matrix( f, p, p, [ coeffs( s*c^k ) for k in range(p) ] )
sage: M
[1 1 2 1 0]
[0 1 1 2 1]
[1 1 1 1 2]
[2 3 1 1 1]
[1 3 3 1 1]

(You want M or M.transpose() .)

dan_fulea gravatar imagedan_fulea ( 8 years ago )