⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mtimes.m

📁 几个关于多小波的程序
💻 M
字号:
function Q = mtimes(P1,P2)

% MTIMES -- product of matrix polynomials
%
%        Q = P1 * P2
%        Q = mtimes(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

% Figure out the size of of the coefficients of Q
% That is not completely trivial: this could be a
% matrix-matrix multiply, or a matrix-scalar multiply
[m1,m2] = size(P1);
[n1,n2] = size(P2);
if (m1*m2 == 1)
    o1 = n1;
    o2 = n2;
elseif (n1*n2 == 1)
    o1 = m1;
    o2 = m2;
else
    o1 = m1;
    o2 = n2;
end
% I don't check whether m2==n1; 
% If the dimensions don't match, Matlab will produce an error later

if (isa(P1,'mpoly'))
    P1 = trim(P1);
    if (isa(P2,'mpoly'))
	P2 = trim(P2);
	Qmin = P1.min + P2.min;
	P1max = get(P1,'max');
	P2max = get(P2,'max');
	Qmax = P1max + P2max;
	Qcoef = zeros(o1,o2,Qmax-Qmin+1);
	if (isa(P1.coef,'sym') | isa(P2.coef,'sym'))
	    Qcoef = sym(Qcoef);
	end
	for k = Qmin:Qmax
	    jmin = max(P2.min,k-P1max);
	    jmax = min(P2max,k-P1.min);
%	    Q{k} = P1{k-jmin}*P2{jmin};
            Qcoef(:,:,k-Qmin+1) = P1.coef(:,:,k-jmin-P1.min+1) * P2.coef(:,:,jmin-P2.min+1);
	    for j = jmin+1:jmax
%		Q{k} = Q{k} + P1{k-j}*P2{j};
                Qcoef(:,:,k-Qmin+1) = Qcoef(:,:,k-Qmin+1) + ...
		    P1.coef(:,:,k-j-P1.min+1) * P2.coef(:,:,j-P2.min+1);
	    end
	end
	[type,m,r] = match_type(P1,P2);
	Q = mpoly(Qcoef,Qmin,type,m,r);
    else
% P2 is a matrix, not a matrix polynomial
	Qcoef = zeros(o1,o2,size(P1.coef,3));
	if (isa(P1.coef,'sym') | isa(P2,'sym'))
	    Qcoef = sym(Qcoef);
	end
	for k = 1:size(Qcoef,3)
%	    Q{k} = P1{k} * P2;
	    Qcoef(:,:,k) = P1.coef(:,:,k) * P2;
	end
	Q = mpoly(Qcoef,P1.min,P1.type,P1.m,P1.r);
    end
else
% P1 is a matrix, not a matrix polynomial
    Qcoef = zeros(o1,o2,size(P2.coef,3));
    if (isa(P1,'sym') | isa(P2.coef,'sym'))
	Qcoef = sym(Qcoef);
    end
    for k = 1:size(Qcoef,3)
%	Q{k} = P1 * P2{k};
	Qcoef(:,:,k) = P1 * P2.coef(:,:,k);
    end
    Q = mpoly(Qcoef,P2.min,P2.type,P2.m,P2.r);
end
Q = trim(Q);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -