Hongyi Zhao on Sun, 15 Jan 2023 02:13:25 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: The companion matrix of a polynomial. |
On Sat, Jan 14, 2023 at 9:58 PM Charles Greathouse <crgreathouse@gmail.com> wrote: > > I'm not at all sure what you're doing here. The GAP source > https://github.com/gap-system/gap/blob/3d47e2bc40869ea1b232a0a658d47b1897880fec/lib/upolyirr.gi#L82 > seems to require that the input to CompanionMat be a polynomial or a list of coefficients of a polynomial. It doesn't seem like it can do anything meaningful to a matrix. I want to get the companion matrix of matrix A in GP, which can be generated in GAP, as shown below: gap> A:=[[-1,3,-1,0,-2,0,0,-2], > [-1,-1,1,1,-2,-1,0,-1], > [-2,-6,4,3,-8,-4,-2,1], > [-1,8,-3,-1,5,2,3,-3], > [0,0,0,0,0,0,0,1], > [0,0,0,0,-1,0,0,0], > [1,0,0,0,2,0,0,0], > [0,0,0,0,4,0,1,0]];; gap> P:=RationalCanonicalFormTransform(A);; gap> C:=A^P; [ [ 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, -1 ], [ 0, 0, 1, 0, 0, 0, 0, -4 ], [ 0, 0, 0, 1, 0, 0, 0, -4 ], [ 0, 0, 0, 0, 1, 0, 0, 2 ], [ 0, 0, 0, 0, 0, 1, 0, 4 ], [ 0, 0, 0, 0, 0, 0, 1, 0 ] ] Best, Zhao > On Sat, Jan 14, 2023 at 8:00 AM Hongyi Zhao <hongyi.zhao@gmail.com> wrote: >> >> On Sat, Jan 14, 2023 at 8:48 PM Charles Greathouse >> <crgreathouse@gmail.com> wrote: >> > >> > If you want the companion matrix if a polynomial in GP, pass the polynomial (not a matrix) to matcompanion. >> >> Is there a convenient command to generate the polynomial of a matrix >> and then feed it to matcompanion? >> >> For example, in my case, I've the following matrix A, so the first >> step is to create the polynomial of it which can be fed to >> matcompanion directly: >> >> A=[ 1, -4, 0; 1, 0, -2; 3, 1, 0 ] >> >> Best regards, >> Zhao >> >> > On Fri, Jan 13, 2023 at 10:21 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote: >> >> >> >> Hi here, >> >> >> >> In GAP, the following command can be used to compute a companion >> >> matrix of the polynomial: >> >> >> >> gap> A:=[ [ 1, -4, 0 ], [ 1, 0, -2 ], [ 3, 1, 0 ] ];; >> >> gap> CompanionMat(A); >> >> [ [ [ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ], [ -1, 4, 0 ] ], [ [ [ >> >> 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ], [ -1, 0, 2 ] ] ] >> >> >> >> When I try the similar operation in GP, the corresponding error will >> >> be triggered: >> >> >> >> ? A=[ 1, -4, 0; 1, 0, -2; 3, 1, 0 ] >> >> %1 = >> >> [1 -4 0] >> >> >> >> [1 0 -2] >> >> >> >> [3 1 0] >> >> >> >> ? matcompanion(A) >> >> *** at top-level: matcompanion(A) >> >> *** ^--------------- >> >> *** matcompanion: incorrect type in matcompanion (t_MAT). >> >> *** Break loop: type 'break' to go back to GP prompt >> >> break> >> >> >> >> Any tips for doing this in GP? >> >> >> >> Regards, >> >> Zhao >> >> -- >> >> Assoc. Prof. Hongsheng Zhao <hongyi.zhao@gmail.com> >> >> Theory and Simulation of Materials >> >> Hebei Vocational University of Technology and Engineering >> >> No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province >> >>