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

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

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

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

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

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

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

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

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

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

找出该多项式的最高指数deg
p
后与前面所得到的∑δi=1ciM(s) 进行比较,从而确定多项式矩阵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;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, ComCtrls, StdCtrls, Gauges;
type sss=array[0..100] of integer;
type
TForm1 = 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;
var
Form1: TForm1;
s:array[0..100,0..100] of sss;
implementation
uses Unit2;
{$R *.dfm}
procedure Tform1.changewidth(col:integer;sender:tstringgrid); var
i,j,k:integer;
begin
k:=32;
i:=form1.Font.Size;
for j:=1 to sender.rowcount do
if length(sender.Cells[col,j])*(i-2)>k then
k:=length(sender.Cells[col,j])*(i-2);
sender.ColWidths[col]:=k;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
row:=1;
col:=1;
self.PageControl1.ActivePageIndex:=0;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
i,j,k:integer;
begin
if form2.ShowModal=mrok then
try
self.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 do
self.StringGrid1.Cells[0,i]:=inttostr(i);
for i:=1 to self.StringGrid1.colCount-1 do
self.StringGrid1.ColWidths[i]:=32;
for i:=1 to self.StringGrid1.colCount-1 do
self.StringGrid1.Cells[i,0]:=inttostr(i);
for i:=1 to self.StringGrid1.ColCount-1 do
for j:=1 to self.StringGrid1.rowCount-1 do
self.StringGrid1.Cells[i,j]:='0';
for i:=1 to 100 do
for j:=1 to 100 do
for k:=0 to 100 do
s[i,j][k]:=0;
self.Edit1.SetFocus;
except
showmessage('无效的行数或列数!');
end;
end;
procedure TForm1.StringGrid1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin
row:=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); begin
if key=#13 then
Edit1Exit(nil);
end;
procedure TForm1.Edit1Exit(Sender: TObject);
var
i,j,k,q:integer;
temp,s1,s2,s3:string;
flag:boolean;
begin
edit1.Text:=lowercase(edit1.text);
flag:=false;
try
for i:=100 downto 1 do
begin
if i<>1 then
j:=pos('s^'+inttostr(i),edit1.text)
else
j:=pos('s',edit1.text);
if (j<>0) then
begin
s[col,row][0]:=i;
flag:=true;
break;
end;
end;
k:=1;
q:=0;
temp:=edit1.text;
if flag then
begin
for i:=s[col,row][0] downto 1 do
begin
if i=1 then
q:=pos('s',temp)
else
q:=pos('s^'+inttostr(i),temp);
if q<>0 then
begin
if q=1 then
s[col,row][k]:=1
else
if (copy(temp,1,q-1)='+') or (copy(temp,1,q-1)='-') then
s[col,row][k]:=strtoint(copy(temp,1,q-1)+'1') else
s[col,row][k]:=strtoint(copy(temp,1,q-1));
if i=1 then
temp:=copy(temp,q+length('s'),1000)
else
temp:=copy(temp,q+length('s^'+inttostr(i)),1000); k:=k+1; end
else
begin
s[col,row][k]:=0;
k:=k+1;
end;
end;
if temp='' then
s[col,row][k]:=0
else
s[col,row][k]:=strtoint(temp);
end
else
begin
s[col,row][0]:=0;
s[col,row][1]:=strtoint(edit1.text);
end;
except
showmessage('表达式格式错误!请按照如下各式输入:'+#13+' 9
s^3+2s^2-3s+1');
exit;
end;
temp:='';
for i:= s[col,row][0] downto 0 do
begin
s1:=inttostr(s[col,row][ abs(i-s[col,row][0])+1 ]); s2:='s^'; s3:=inttostr(i);
if strtoint(s3)=0 then
begin
s2:='';s3:='';
end
else if strtoint(s3)=1 then
begin
s2:='s';s3:='';
end;
if (strtoint(s1)=0) then
begin
if (s[col,row][0]<>0) then
s1:=''
else
s1:='0';
s2:='';
s3:='';
end
else
begin
if (strtoint(s1)>0) and (i<>s[col,row][0]) then s1:='+'+s1;
if i<>0 then
begin
if 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 then
begin
self.StringGrid1.Cells[col,row]:=temp;
changewidth(col,stringgrid1);
end
else
begin
showmessage('表达式格式错误!请按照如下各式输入:'+#13+' s^3+2s^2-3s+1'); exit;
end;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
edit1.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);
var
i:integer;
begin
if self.PageControl1.ActivePageIndex=1 then
begin
self.StringGrid2.ColCount:=self.StringGrid1.ColCount;
self.StringGrid2.rowCount:=self.StringGrid1.rowCount+1;
for i:=1 to self.StringGrid2.rowCount-2 do
self.StringGrid2.Cells[0,i]:=inttostr(i);
self.StringGrid2.cells[0,self.StringGrid2.rowCount-1]:='列最高次数'; for i:=1 to self.StringGrid2.colCount-1 do
self.StringGrid2.ColWidths[i]:=32;
for i:=1 to self.StringGrid2.colCount-1 do
self.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;
var
mc,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 do
for mr:=1 to self.StringGrid1.rowCount-1 do
begin
self.StringGrid2.Cells[mc,mr]:=self.StringGrid1.Cells[mc,mr]; changewidth(mc,self.StringGrid2);
end;
//计算kc
colsum:=0;
for mc:=1 to self.StringGrid2.colCount-1 do
begin
max:=0;
for mr:=1 to self.StringGrid2.rowCount-2 do
begin
if s[mc,mr][0]>max then
max:=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 do
begin
s1:=inttostr(det[abs(aa-det[0])+1]);
s2:='s^';
s3:=inttostr(aa);
if strtoint(s3)=0 then
begin
s2:='';s3:='';
end
else if strtoint(s3)=1 then
begin
s2:='s';s3:='';
end;
if (strtoint(s1)=0) then
begin
if (det[0]<>0) then
s1:=''
else
s1:='0';
s2:='';
s3:='';
end
else
begin
if (strtoint(s1)>0) and (aa<>det[0]) then s1:='+'+s1;
if aa<>0 then
begin
if 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) then
begin
str1:='M(s)是奇异的';
str2:='M(s)不是列既约';
end
else
begin
str1:='M(s)是非奇异的';
if deg=colsum then
str2:=str2+'M(s)是列既约的'
else
str2:=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;
var
n,aa:integer;
a:array[1..100] of integer;
str:string;
he,ji,ji_temp:sss;
procedure kkk(y:integer);
var
m,q,k,j:integer; //k第几层 m,j循环变量 a1,a2,a3,a4,flag:integer; begin
k:=y+1;
if k=n+1 then //求det
begin
//求乘积
for a1:=0 to 100 do
ji[a1]:=0;
ji[1]:=1;
for a1:=1 to n do //s[a1,a[a1]]*ji
begin
ji_temp:=ji;
ji[0]:=ji[0]+s[a1,a[a1]][0];
for a4:=1 to 100 do
ji[a4]:=0;
for a2:=1 to s[a1,a[a1]][0]+1 do
for a3:=1 to ji_temp[0]+1 do
begin
ji[a2+a3-1]:=ji[a2+a3-1]+ji_temp[a3]*s[a1,a[a1]][a2]; end; end;
//求和
//统一次数
if he[0]<ji[0] then
begin
for a1:=he[0]+1 downto 1 do
he[a1+ji[0]-he[0]]:=he[a1];
for a1:=ji[0]-he[0] downto 1 do
he[a1]:=0;
he[0]:=ji[0];
end;
if ji[0]<he[0] then
begin
for a1:=ji[0]+1 downto 1 do
ji[a1+he[0]-ji[0]]:=ji[a1];
for a1:=he[0]-ji[0] downto 1 do
ji[a1]:=0;
ji[0]:=he[0];
end;
//累加
flag:=0;
for a1:=1 to n do
for a2:=a1 to n do
if a[a1]>a[a2] then
flag:=flag+1;
if ( flag mod 2) =0 then
flag:=1
else
flag:=-1;
for a1:=1 to he[0]+1 do
he[a1]:=he[a1]+flag*ji[a1];
for a1:=1 to 100 do
if (he[1]=0) and (he[0]<>0) then
begin
for a2:=1 to he[0]+1 do
he[a2]:=he[a2+1];
he[0]:=he[0]-1;
end;
exit;
end;
for j:=1 to n do //产生数据
begin
a[k]:=j;
q:=0; //检查有无重复数据 for m:=1 to k-1 do
if a[m]=j then q:=q+1;
if q=0 then
kkk(k);
end;
end;
begin
for aa:=0 to 100 do
he[aa]:=0;
n:=self.StringGrid1.ColCount-1;
kkk(0);
caldet:=he;
end;
procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean);
begin
allowchange:=edit1.Enabled
end;
end.。

相关文档
最新文档