📄 times.m
字号:
function Q = times(P1,P2)
% TIMES -- elementwise product of matrix polynomial objects
%
% Q = P1 .* P2
% Q = times(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. The effect is
%
%
% Q = P1 .* P2 if P2 is a regular matrix
% k k
%
% Q = P1 .* P2 if P1 is a regular matrix
% k k
%
% Q = P1 .* P2 if P1, P2 are both matrix polynomials
% k k k
%
% I am not sure if this routine has any useful applications, but I
% wrote it for completeness.
% 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'))
if (isa(P2,'mpoly'))
Q = trim(P2);
P2max = get(Q,'max');
P1 = trim(P1,[P2.min,P2max]);
n = size(Q.coef);
% this reshape business is necessary for symbolic matrix polynomials
Q.coef = reshape(P1.coef(:) .* Q.coef(:),n);
else
% P2 is a matrix, not a matrix polynomial
Q = trim(P1);
if (isa(P2,'sym') & ~isa(Q.coef,'sym'))
Q = sym(Q);
end
for k = 1:size(Q.coef,3)
% Q{k} = P1{k} .* P2;
Q.coef(:,:,k) = P1.coef(:,:,k) * P2;
end
end
else
% P1 is a matrix, not a matrix polynomial
Q = trim(P2);
if (isa(P1,'sym') & ~isa(Q.coef,'sym'))
Q = sym(Q);
end
for k = 1:size(Q.coef,3)
% Q{k} = P1 .* P2{k};
Q.coef(:,:,k) = P1 .* P2.coef(:,:,k);
end
end
Q = trim(Q);
[type,m,r] = match_type(P1,P2);
Q = set(Q,'type',type,'m',m,'r',r);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -