ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 04 May 2017 04:08:20 +0200converting linear map to matrix representationhttps://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/ 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...Tue, 02 May 2017 23:13:58 +0200https://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/Comment by tmonteil for <p>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...</p>
https://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/?comment=37495#post-id-37495As 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) ?Wed, 03 May 2017 08:13:26 +0200https://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/?comment=37495#post-id-37495Comment by gelatine1 for <p>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...</p>
https://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/?comment=37498#post-id-37498p=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 thatWed, 03 May 2017 16:17:51 +0200https://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/?comment=37498#post-id-37498Comment by dan_fulea for <p>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...</p>
https://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/?comment=37499#post-id-37499(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...)Thu, 04 May 2017 01:33:46 +0200https://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/?comment=37499#post-id-37499Comment by dan_fulea for <p>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...</p>
https://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/?comment=37501#post-id-37501The 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]Thu, 04 May 2017 03:40:00 +0200https://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/?comment=37501#post-id-37501Comment by dan_fulea for <p>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...</p>
https://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/?comment=37503#post-id-37503With 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()` .)Thu, 04 May 2017 04:06:31 +0200https://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/?comment=37503#post-id-37503Comment by dan_fulea for <p>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...</p>
https://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/?comment=37504#post-id-37504(I could not find a structural approach based on `F.vector_space()` or on `VectorSpace` .)Thu, 04 May 2017 04:08:20 +0200https://ask.sagemath.org/question/37493/converting-linear-map-to-matrix-representation/?comment=37504#post-id-37504