converting linear map to matrix representation

asked 2017-05-02 16:13:58 -0500

gelatine1 gravatar image

I have a linear map $\alpha$ from $F_{p^n} \longrightarrow F_{p^n}$, where we see $F_{p^n}$ as a vector space over $F_p$ with a $V_i$ as base elements. I want to create the matrix representation for $\alpha$. For that I have to calculate $\alpha(V_i)$ and then write it in the basis $V_i$ 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...

edit retag flag offensive close merge delete

Comments

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

tmonteil gravatar imagetmonteil ( 2017-05-03 01:13:26 -0500 )edit

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 ( 2017-05-03 09:17:51 -0500 )edit

(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 ( 2017-05-03 18:33:46 -0500 )edit

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 $\mathbb 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 ( 2017-05-03 20:40:00 -0500 )edit

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 ( 2017-05-03 21:06:31 -0500 )edit