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

📄 kron.m

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

% KRON -- Kronecker product of matrix polynomials
%
%        Q = kron(P1,P2)
%
% To visualize this, it helps to think of P1, P2 as matrices with
% polynomial entries, rather than as polynomials with matrix coefficients.

% 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 = trim(P1);
    if (isa(P2,'mpoly'))
	P2 = trim(P2);
	[p1,p2,p3] = size(P1.coef);
	[q1,q2,q3] = size(P2.coef);
	Qmin = P1.min + P2.min;
	P1max = get(P1,'max');
	P2max = get(P2,'max');
	Qmax = P1max + P2max;
	Q = mpoly(zeros(p1*q1,p2*q2,Qmax-Qmin+1),Qmin);
	if (isa(P1,'sym') | isa(P2,'sym'))
	    Q = sym(Q);
	end
	for k = Qmin:Qmax
	    jmin = max(P2.min,k-P1max);
	    jmax = min(P2max,k-P1.min);
%	    Q{k} = kron(P1{k-jmin},P2{jmin});
	    Q.coef(:,:,k-Qmin+1) = kron(P1.coef(:,:,k-jmin-P1.min+1),...
					 P2.coef(:,:,jmin-P2.min+1));
	    for j = jmin+1:jmax
%		Q{k} = Q{k} + kron(P1{k-j},P2{j});
		Q.coef(:,:,k-Qmin+1) = Q.coef(:,:,k-Qmin+1) + ...
		    kron(P1.coef(:,:,k-j-P1.min+1),P2.coef(:,:,j-P2.min+1));
	    end
	end
    else
% P2 is a matrix, not a matrix polynomial
	Q = P1;
	if (~isa(P1,'sym') & isa(P2,'sym'))
	    Q = sym(Q);
	end
	Qmax = get(Q,'max');
	for k = Q.min:Qmax
%	    Q{k} = kron(P1{k},P2);
	    Q.coef(:,:,k-Q.min+1) = kron(P1.coef(:,:,k-P1.min+1),P2);
	end
    end
else 
% P1 is a matrix, not a matrix polynomial
    P2 = trim(P2);
    Q = P2;
    if (isa(P1,'sym') & ~isa(P2,'sym'))
	Q = sym(Q);
    end
    Qmax = get(Q,'max');
    for k = Q.min:Qmax
%	Q{k} = kron(P1,P2{k});
	Q.coef(:,:,k-Q.min+1) = kron(P1,P2.coef(k-P2.min+1));
    end
end

[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 + -