1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
// polmul
// The command
// [C,degA] = polmul(A,degA,B,degB)
// produces the polynomial matrix C that equals the product A*B of the
// polynomial matrices A and B.
//
// H. Kwakernaak, July, 1990
function [C,degC] = polmul(A,degA,B,degB)
[rA,cA] = polsize(A,degA);
[rB,cB] = polsize(B,degB);
if cA ~= rB
error('polmul: Inconsistent dimensions of input matrices');
end
degC = degA+degB;
C = [];
for k = 0:degA+degB
mi = 0;
if k-degB > mi
mi = k-degB;
end
ma = degA;
if k < ma
ma = k;
end
Ck = zeros(rA,cB);
for i = mi:ma
Ck = Ck + A(:,i*cA+1:(i+1)*cA)*B(:,(k-i)*cB+1:(k-i+1)*cB);
end
C = [C Ck];
end
endfunction
|