📄 plus.m
字号:
function M = plus(P1,P2)
% PLUS -- addition of matrix polynomials
%
% M = P1 + P2
% M = plus(P1,P2)
%
% This function is not meant to be called by the user. It is called by
% Matlab if an expression of the form P1+P2 is encountered, where at
% least one of the two operands is a matrix polynomial.
% Copyright (c) 2004 by Fritz Keinert (keinert@iastate.edu),
% Dept. of Mathematics, Iowa State University, Ames, IA 50011.
% This software may be freely used and distributed for non-commercial
% purposes, provided this copyright statement is preserved, and
% appropriate credit for its use is given.
%
% Last update: Feb 20, 2004
if ~isa(P1,'mpoly')
P1 = mpoly(P1);
end
if ~isa(P2,'mpoly')
P2 = mpoly(P2);
end
% check whether one of the terms is a scalar
% if yes, make it into a matrix of the same size as the other
n = size(P1);
m = size(P2);
if (prod(n) == 1 & prod(m) ~= 1)
P1 = P1 * ones(m);
elseif (prod(n) ~= 1 & prod(m) == 1)
P2 = P2 * ones(n);
end
Mmin = min(P1.min,P2.min);
Mmax = max(get(P1,'max'),get(P2,'max'));
P1 = trim(P1,[Mmin,Mmax]);
P2 = trim(P2,[Mmin,Mmax]);
% the "reshape" construction is necessary because Matlab
% cannot handle three-dimensional symbolic matrices correctly
n = size(P1.coef);
P3 = reshape(P1.coef(:) + P2.coef(:),n);
M = trim(mpoly(P3,Mmin));
[type,m,r] = match_type(P1,P2);
M = set(M,'type',type,'m',m,'r',r);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -