当前位置:文档之家› 一种多项式矩阵列既约分析方法

一种多项式矩阵列既约分析方法

一种多项式矩阵列既约分析方法一、目的与用途在多项式矩阵分析中,矩阵的既约性是一个很重要的问题,本文介绍了针对pXp 阶多项式矩阵M(s) 的分析方法,并给出了确定其是否列既约的计算机程序。

经过输入处理也可实现行既约的分析。

二、数学原理给定一个pXp 的非奇异多项式矩阵M(s)称为是列既约的,如果满足下述条件∑==pi cis M s M 1)()(det deg δ用程序实现时,要先定义一二维数组W[x][x]存放多项式矩阵,矩阵元素为一维整型数组类型,存放多项式的系数和首项次数。

通过键盘输入多项式,对所输入的多项式进行分析处理,得到二维数组w[x][x],每个多项式对应一个一维数组。

根据每个多项式对应的一维数组,得到该多项式的最高指数。

通过对二维数组w[x][x]的搜索,得到每一列最高指数的最大值。

然后对所得到的最高指数的最大值分别按列进行累加, 得到∑=pi cis M 1)(δ。

其次,求出二维数组w[x][x]所对应的多项式矩阵的行列式的值,即 )(det s M ,npn p p p p ia a a a as M ...)1()(det 44332211∑-=,其中p1p2p3p4…pn 为从1到n 所有整数的某种排列结果,i 为p1p2p3p4…pn 的逆序数。

找出该多项式的最高指数 )(det degs M ,然后与前面所得到的∑=pi cis M 1)(δ进行比较,从而确定多项式矩阵M(s)的列既约性。

三、程序流程图四、使用说明1.运行程序project1.exe;2.按初始化键,输入多项式矩阵的行数和列数;3.点击输入窗口可输入相应多项式。

输入多项式的格式如下所示:s^6+7s^5+3s^2-4s-125其中s的最高次数不能超过99,输入时次数由高到低排列;4.进行列既约分析;输出结果将显示在屏幕上;5.关闭程序。

五、举例例1:例2:附:软件清单(编程环境windows2000+delphi6)unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, ComCtrls, StdCtrls, Gauges;type sss=array[0..100] of integer;typeTForm1 = class(TForm)PageControl1: TPageControl;TabSheet1: TTabSheet;TabSheet2: TTabSheet;StringGrid1: TStringGrid;Button4: TButton;Edit1: TEdit;Label1: TLabel;StringGrid2: TStringGrid;Label2: TLabel;procedure FormCreate(Sender: TObject);procedure Button4Click(Sender: TObject);procedure StringGrid1MouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);procedure Edit1KeyPress(Sender: TObject; var Key: Char);procedure Edit1Exit(Sender: TObject);procedure FormResize(Sender: TObject);procedure PageControl1Change(Sender: TObject);procedure PageControl1Changing(Sender: TObject;var AllowChange: Boolean);private{ Private declarations }row,col:integer;procedure jyjs;function caldet:sss;public{ Public declarations }procedure changewidth(col:integer;sender:tstringgrid);end;varForm1: TForm1;s:array[0..100,0..100] of sss;implementationuses Unit2;{$R *.dfm}procedure Tform1.changewidth(col:integer;sender:tstringgrid); vari,j,k:integer;begink:=32;i:=form1.Font.Size;for j:=1 to sender.rowcount doif length(sender.Cells[col,j])*(i-2)>k thenk:=length(sender.Cells[col,j])*(i-2);sender.ColWidths[col]:=k;end;procedure TForm1.FormCreate(Sender: TObject);beginrow:=1;col:=1;self.PageControl1.ActivePageIndex:=0;end;procedure TForm1.Button4Click(Sender: TObject);vari,j,k:integer;beginif form2.ShowModal=mrok thentryself.StringGrid1.Enabled:=true;self.Edit1.Enabled:=true;edit1.text:='0';self.StringGrid1.ColCount:=strtoint(form2.colnumber.text)+1; self.StringGrid1.rowCount:=strtoint(form2.rownumber.text)+1; self.StringGrid1.FixedCols:=1;self.StringGrid1.Fixedrows:=1;for i:=1 to self.StringGrid1.rowCount-1 doself.StringGrid1.Cells[0,i]:=inttostr(i);for i:=1 to self.StringGrid1.colCount-1 doself.StringGrid1.ColWidths[i]:=32;for i:=1 to self.StringGrid1.colCount-1 doself.StringGrid1.Cells[i,0]:=inttostr(i);for i:=1 to self.StringGrid1.ColCount-1 dofor j:=1 to self.StringGrid1.rowCount-1 doself.StringGrid1.Cells[i,j]:='0';for i:=1 to 100 dofor j:=1 to 100 dofor k:=0 to 100 dos[i,j][k]:=0;self.Edit1.SetFocus;exceptshowmessage('无效的行数或列数!');end;end;procedure TForm1.StringGrid1MouseDown(Sender: TObject;Button: TMouseButton; Shift: TShiftState; X, Y: Integer);beginrow:=self.StringGrid1.row;col:=self.StringGrid1.col;label1.Caption:='s('+inttostr(row)+','+inttostr(col)+')=';edit1.Text:=self.StringGrid1.Cells[col,row];edit1.Left:=label1.Left+label1.Width+5;edit1.Width:=StringGrid1.Left+StringGrid1.Width-edit1.Left; edit1.SetFocus;end;procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); beginif key=#13 thenEdit1Exit(nil);end;procedure TForm1.Edit1Exit(Sender: TObject);vari,j,k,q:integer;temp,s1,s2,s3:string;flag:boolean;beginedit1.Text:=lowercase(edit1.text);flag:=false;tryfor i:=100 downto 1 dobeginif i<>1 thenj:=pos('s^'+inttostr(i),edit1.text)elsej:=pos('s',edit1.text);if (j<>0) thenbegins[col,row][0]:=i;flag:=true;break;end;end;k:=1;q:=0;temp:=edit1.text;if flag thenbeginfor i:=s[col,row][0] downto 1 dobeginif i=1 thenq:=pos('s',temp)elseq:=pos('s^'+inttostr(i),temp);if q<>0 thenbeginif q=1 thens[col,row][k]:=1elseif (copy(temp,1,q-1)='+') or (copy(temp,1,q-1)='-') thens[col,row][k]:=strtoint(copy(temp,1,q-1)+'1')elses[col,row][k]:=strtoint(copy(temp,1,q-1));if i=1 thentemp:=copy(temp,q+length('s'),1000)elsetemp:=copy(temp,q+length('s^'+inttostr(i)),1000);k:=k+1;endelsebegins[col,row][k]:=0;k:=k+1;end;end;if temp='' thens[col,row][k]:=0elses[col,row][k]:=strtoint(temp);endelsebegins[col,row][0]:=0;s[col,row][1]:=strtoint(edit1.text);end;exceptshowmessage('表达式格式错误!请按照如下各式输入:'+#13+'s^3+2s^2-3s+1');exit;end;temp:='';for i:= s[col,row][0] downto 0 dobegins1:=inttostr(s[col,row][ abs(i-s[col,row][0])+1 ]); s2:='s^';s3:=inttostr(i);if strtoint(s3)=0 thenbegins2:='';s3:='';endelse if strtoint(s3)=1 thenbegins2:='s';s3:='';end;if (strtoint(s1)=0) thenbeginif (s[col,row][0]<>0) thens1:=''elses1:='0';s2:='';s3:='';endelsebeginif (strtoint(s1)>0) and (i<>s[col,row][0]) then s1:='+'+s1;if i<>0 thenbeginif s1='-1' then s1:='-';if s1='+1' then s1:='+';if s1='1' then s1:='';end;end;temp:=temp+s1+s2+s3;end;if temp='' then temp:='0';if temp=edit1.Text thenbeginself.StringGrid1.Cells[col,row]:=temp;changewidth(col,stringgrid1);endelsebeginshowmessage('表达式格式错误!请按照如下各式输入:'+#13+' s^3+2s^2-3s+1');exit;end;end;procedure TForm1.FormResize(Sender: TObject);beginedit1.Text:=self.StringGrid1.Cells[col,row];edit1.Left:=label1.Left+label1.Width+5;edit1.Width:=StringGrid1.Left+StringGrid1.Width-edit1.Left;end;procedure TForm1.PageControl1Change(Sender: TObject);vari:integer;beginif self.PageControl1.ActivePageIndex=1 thenbeginself.StringGrid2.ColCount:=self.StringGrid1.ColCount;self.StringGrid2.rowCount:=self.StringGrid1.rowCount+1;for i:=1 to self.StringGrid2.rowCount-2 doself.StringGrid2.Cells[0,i]:=inttostr(i);self.StringGrid2.cells[0,self.StringGrid2.rowCount-1]:='列最高次数';for i:=1 to self.StringGrid2.colCount-1 doself.StringGrid2.ColWidths[i]:=32;for i:=1 to self.StringGrid2.colCount-1 doself.StringGrid2.Cells[i,0]:=inttostr(i);self.StringGrid2.ColWidths[0]:=70;self.StringGrid2.ColWidths[self.StringGrid2.colCount-1]:=70;jyjs;end;end;procedure tform1.jyjs;varmc,mr,max,colsum,rowsum,deg,aa:integer;det:sss;detstr,str1,str2,s1,s2,s3:string;begin//复制原矩阵label2.caption:='';for mc:=1 to self.StringGrid1.ColCount-1 dofor mr:=1 to self.StringGrid1.rowCount-1 dobeginself.StringGrid2.Cells[mc,mr]:=self.StringGrid1.Cells[mc,mr];changewidth(mc,self.StringGrid2);end;//计算kccolsum:=0;for mc:=1 to self.StringGrid2.colCount-1 dobeginmax:=0;for mr:=1 to self.StringGrid2.rowCount-2 dobeginif s[mc,mr][0]>max thenmax:=s[mc,mr][0];end;self.StringGrid2.cells[mc,self.StringGrid2.rowCount-1]:=inttostr(max); colsum:=colsum+max;end;//计算det M(s)det:=caldet;deg:=det[0];detstr:='';for aa:= det[0] downto 0 dobegins1:=inttostr(det[abs(aa-det[0])+1]);s2:='s^';s3:=inttostr(aa);if strtoint(s3)=0 thenbegins2:='';s3:='';endelse if strtoint(s3)=1 thenbegins2:='s';s3:='';end;if (strtoint(s1)=0) thenbeginif (det[0]<>0) thens1:=''elses1:='0';s2:='';s3:='';endelsebeginif (strtoint(s1)>0) and (aa<>det[0]) then s1:='+'+s1;if aa<>0 thenbeginif s1='-1' then s1:='-';if s1='+1' then s1:='+';if s1='1' then s1:='';end;end;detstr:=detstr+s1+s2+s3;end;//显示结果str2:='';if (det[0]=0) and (det[1]=0) thenbeginstr1:='M(s)是奇异的';str2:='M(s)不是列既约';endelsebeginstr1:='M(s)是非奇异的';if deg=colsum thenstr2:=str2+'M(s)是列既约的'elsestr2:=str2+'M(s)不是列既约的';end;label2.caption:=str1+' '+'∑kc='+inttostr(colsum)+' '+#13+ 'det M(s)='+detstr+' '+'deg det M(s)='+inttostr(deg)+#13+str2;end;function tform1.caldet:sss;varn,aa:integer;a:array[1..100] of integer;str:string;he,ji,ji_temp:sss;procedure kkk(y:integer);varm,q,k,j:integer; //k第几层 m,j循环变量a1,a2,a3,a4,flag:integer;begink:=y+1;if k=n+1 then //求detbegin//求乘积for a1:=0 to 100 doji[a1]:=0;ji[1]:=1;for a1:=1 to n do //s[a1,a[a1]]*jibeginji_temp:=ji;ji[0]:=ji[0]+s[a1,a[a1]][0];for a4:=1 to 100 doji[a4]:=0;for a2:=1 to s[a1,a[a1]][0]+1 dofor a3:=1 to ji_temp[0]+1 dobeginji[a2+a3-1]:=ji[a2+a3-1]+ji_temp[a3]*s[a1,a[a1]][a2]; end;end;//求和//统一次数if he[0]<ji[0] thenbeginfor a1:=he[0]+1 downto 1 dohe[a1+ji[0]-he[0]]:=he[a1];for a1:=ji[0]-he[0] downto 1 dohe[a1]:=0;he[0]:=ji[0];end;if ji[0]<he[0] thenbeginfor a1:=ji[0]+1 downto 1 doji[a1+he[0]-ji[0]]:=ji[a1];for a1:=he[0]-ji[0] downto 1 doji[a1]:=0;ji[0]:=he[0];end;//累加flag:=0;for a1:=1 to n dofor a2:=a1 to n doif a[a1]>a[a2] thenflag:=flag+1;if ( flag mod 2) =0 thenflag:=1elseflag:=-1;for a1:=1 to he[0]+1 dohe[a1]:=he[a1]+flag*ji[a1];for a1:=1 to 100 doif (he[1]=0) and (he[0]<>0) thenbeginfor a2:=1 to he[0]+1 dohe[a2]:=he[a2+1];he[0]:=he[0]-1;end;exit;end;for j:=1 to n do //产生数据begina[k]:=j;q:=0; //检查有无重复数据for m:=1 to k-1 doif a[m]=j then q:=q+1;if q=0 thenkkk(k);end;end;beginfor aa:=0 to 100 dohe[aa]:=0;n:=self.StringGrid1.ColCount-1;kkk(0);caldet:=he;end;procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean);beginallowchange:=edit1.Enabledend;end.。

相关主题