Polynomial Computations in MATLAB. 1. Kannan M. Moudgalya. Dept. of
Chemical Engineering and. Systems and Control Group. Indian Institute of
Technology.
Polynomial Computations in MATLAB1 Kannan M. Moudgalya Dept. of Chemical Engineering and Systems and Control Group Indian Institute of Technology Powai, Mumbai 400 076 India November 1996
1 Supported
ET
by the Department of Science and Technology through Grant No. III.5(11)/91-
Abstract This report details how the following polynomial matrix computations have been implemented in MATLAB: coprime factorization, solutions to Aryabhatta’s Identity and unilateral and bilateral polynomial equations. A complete listing of the source code is provided. Usage of the software is illustrated with several examples.
Contents 1 Introduction
1
2 Left coprime factorization 2.1 Algorithm (Chang and Pearson, 1982) . . . . . . . . . . 2.2 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Example: Coprime factorization . . . . . . . . . . . . . . 2.3.1 Input program listing (data01.m) . . . . . . . . . 2.3.2 Output from MATLAB . . . . . . . . . . . . . . . 2.3.3 Result . . . . . . . . . . . . . . . . . . . . . . . . 2.4 Example: Checking whether a given polynomial matrix is 2.4.1 Input program listing . . . . . . . . . . . . . . . . 2.4.2 Output from MATLAB . . . . . . . . . . . . . . . 2.5 Example: Producing a row proper polynomial . . . . . . 2.5.1 Input program listing . . . . . . . . . . . . . . . . 2.5.2 Output from MATLAB . . . . . . . . . . . . . . . 2.6 Programs . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
3 3 4 5 5 6 6 7 7 7 8 8 8 9
. . . . . .
10 10 10 10 11 12 12
. . . . .
12 12 13 13 14 15
. . . . .
16 16 16 16 17 17
3 Aryabhatta’s Identity 3.1 Algorithm (Chang and Pearson, 1982) . . 3.2 Usage . . . . . . . . . . . . . . . . . . . . 3.2.1 Input program listing (data04.m) . 3.2.2 Output from MATLAB (ex04.out) 3.2.3 Result . . . . . . . . . . . . . . . . 3.3 Programs . . . . . . . . . . . . . . . . . . 4 Unilateral polynomial matrix equation 4.1 Algorithm (Chang and Pearson, 1982) 4.2 Usage . . . . . . . . . . . . . . . . . . 4.2.1 First example . . . . . . . . . . 4.2.2 Second example . . . . . . . . . 4.3 Programs . . . . . . . . . . . . . . . .
. . . . .
. . . . .
5 Generalized Aryabhatta’s Identity 5.1 Algorithm (Chang and Pearson, 1982) . . 5.1.1 Step1: Find A(s) and B(s) . . . . . 5.1.2 Step2: Find A1 (s), B1 (s), X(s) and 5.1.3 Step 3: Find X1 (s) and Y1 (s) . . . 5.2 Usage . . . . . . . . . . . . . . . . . . . . i
. . . . . .
. . . . .
. . . . . .
. . . . .
. . . . . .
. . . . .
. . . . . . Y (s) . . . . . .
. . . . . .
. . . . .
. . . . .
. . . . . .
. . . . .
. . . . .
. . . . . .
. . . . .
. . . . .
. . . . . .
. . . . .
. . . . .
. . . . . .
. . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . unimodular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . .
. . . . .
. . . . . .
. . . . .
. . . . .
. . . . . .
. . . . .
. . . . .
. . . . . .
. . . . .
. . . . .
. . . . . .
. . . . .
. . . . .
. . . . . .
. . . . .
. . . . .
. . . . . .
. . . . .
. . . . .
. . . . . . . . . . . . .
. . . . . .
. . . . .
. . . . .
5.3
5.2.1 First example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.2 Second example . . . . . . . . . . . . . . . . . . . . . . . . . . . . Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6 Bilateral polynomial matrix equation 6.1 Algorithm (Chang and Pearson, 1982) 6.2 Usage . . . . . . . . . . . . . . . . . . 6.2.1 First example . . . . . . . . . . 6.2.2 Second example . . . . . . . . . 6.3 Programs . . . . . . . . . . . . . . . .
17 19 22
. . . . .
22 23 23 23 24 26
7 Numerical issues 7.1 Linear dependence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2 Zeroing small entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
26 27 27
A MATLAB routines A.1 arya.m . . . . . . . . . . . A.1.1 Purpose . . . . . . A.1.2 mfiles called . . . . A.1.3 Listing of the code A.2 cindep.m . . . . . . . . . . A.2.1 Purpose . . . . . . A.2.2 mfiles called . . . . A.2.3 Listing of the code A.3 clcoef.m . . . . . . . . . . A.3.1 Purpose . . . . . . A.3.2 mfiles called . . . . A.3.3 Listing of the code A.4 flat2nor.m . . . . . . . . . A.4.1 Purpose . . . . . . A.4.2 mfiles called . . . . A.4.3 Listing of the code A.5 indep.m . . . . . . . . . . A.5.1 Purpose . . . . . . A.5.2 mfiles called . . . . A.5.3 Listing of the code A.6 issoln.m . . . . . . . . . . A.6.1 Purpose . . . . . . A.6.2 mfiles called . . . .
28 28 28 28 28 29 29 29 29 30 30 30 30 31 31 31 31 32 32 32 32 33 33 33
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . ii
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
A.6.3 Listing of the code A.7 l2r.m . . . . . . . . . . . . A.7.1 Purpose . . . . . . A.7.2 mfiles called . . . . A.7.3 Listing of the code A.8 left prm.m . . . . . . . . . A.8.1 Purpose . . . . . . A.8.2 mfiles called . . . . A.8.3 Listing of the code A.9 makezero.m . . . . . . . . A.9.1 Purpose . . . . . . A.9.2 mfiles called . . . . A.9.3 Listing of the code A.10 move.m . . . . . . . . . . A.10.1 Purpose . . . . . . A.10.2 mfiles called . . . . A.10.3 Listing of the code A.11 nor2flat.m . . . . . . . . . A.11.1 Purpose . . . . . . A.11.2 mfiles called . . . . A.11.3 Listing of the code A.12 polksca.m . . . . . . . . . A.12.1 Purpose . . . . . . A.12.2 mfiles called . . . . A.12.3 Listing of the code A.13 scakpol.m . . . . . . . . . A.13.1 Purpose . . . . . . A.13.2 mfiles called . . . . A.13.3 Listing of the code A.14 seshft.m . . . . . . . . . . A.14.1 Purpose . . . . . . A.14.2 mfiles called . . . . A.14.3 Listing of the code A.15 t1calc.m . . . . . . . . . . A.15.1 Purpose . . . . . . A.15.2 mfiles called . . . . A.15.3 Listing of the code A.16 xdnyc.m . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
33 34 34 34 34 34 34 34 35 37 37 37 37 38 38 38 38 38 38 38 38 39 39 39 39 40 40 40 40 40 40 40 41 41 41 41 41 42
A.16.1 Purpose . . . . . . A.16.2 mfiles called . . . . A.16.3 Listing of the code A.17 xdync.m . . . . . . . . . . A.17.1 Purpose . . . . . . A.17.2 mfiles called . . . . A.17.3 Listing of the code
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
iv
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
42 42 43 43 43 43 43
1
Introduction
In this report we present MATLAB version of programs to carry out polynomial calcuations. The algorithms used here were proposed by Chang and Pearson (1982) and implemented in FORTRAN by Chang (1982). Kwakernaak’s (1990) convention of representing polynomials in MATLAB has been adopted in this work. In the control literature, the use of polynomial calculations has been reported in discrete control in general (Kucera, 1979; Hunt, 1993; Grimble and Kucera, 1996; Astrom and Wittenmark 1990), regulator theory (Cheng and Pearson, 1981), `1 optimal control theory (Pearson, 1991), H∞ optimal control theory (Kwakernaak 1990) and behavioral theory (Willems, 1991) in particular, to cite a few references. These theories require coprime factorizations so often that a numerically stable implementation is indispensable. The numerical stability of the current implementation is decided by the following two calculations: 1. When does a set of vectors become dependent 2. What is a small number so that one can zero it It is possible to improve the speed and the stability of the current implementation by making the above two calculations more efficient. This report is organized as follows: Section 2 describes the following computations: • Given a transfer function matrix H(s) = N (s)D(s)−1
(1)
N (s), D(s) not necessarily coprime, D(s) nonsingular, compute coprime polynomial matrices A(s) and B(s) such that A(s)−1 B(s) = H(s)
(2)
and A(s) row proper. • Given two matrices N (s) and D(s) with D(s) nonsingular, check if N (s)D−1 (s) is a polynomial matrix. • Given a polynomial matrix D(s), find a unimodular matrix W (s) and a row proper ˆ D(s) so that ˆ W (s)D(s) = D(s) (3) 1
Section 3 describes the following computation: Given coprime polynomial matrices N (s) and D(s) with D(s) column proper, find polynomial matrices X(s) and Y (s) satisfying the following identity. X(s)D(s) + Y (s)N (s) = I
(4)
This equation has been known as Bezout Identity (Kailath, 1980) and Aryabhatta’s Identity (Vidyasagar, 1985). In this report, we will refer to it as the Aryabhatta’s Identity.
Section 4 describes the following computation: Given polynomial matrices N (s), D(s) and C(s) with D(s) nonsingular, find polynomial matrices X(s) and Y (s) satisfying X(s)D(s) + Y (s)N (s) = C(s)
(5)
if the above equation can be solved. This equation has been known as the Diophantine Equation and Aryabhatta’s Identify in the literature. We will refer to it as the unilateral polynomial matrix equation (Kucera, 1979).
Section 5 describes the following computation: Given arbitrary matrices N (s), D(s) as given in Eq. 1, D(s) nonsingular, find the matrices in the following generalized Aryabhatta’s Identity
I 0 A(s) B(s) X(s) −B1 (s) = −Y1 (s) X1 (s) Y (s) A1 (s) 0 I
(6)
A(s)−1 B(s) = B1 (s)A1 (s)−1 = H(s)
(7)
with
Section 6 describes the following computation: Given polynomial matrices N (s), D(s) and C(s) with D(s) nonsingular, find polynomial matrices X(s) and Y (s) satisfying X(s)D(s) + N (s)Y (s) = C(s)
(8)
if the above equation can be solved. This equation is known as the bilateral polynomial matrix equation (Kucera, 1979).
Section 7 is devoted to numerical issues, such as, when a set of vectors is dependent and how to decide whether a given number is small. 2
2
Left coprime factorization
In this section we will be concerned with the calculation of B(s) and A(s) matrices satisfying Eq. 2, given matrices satisfying Eq. 1. Equivalently, we need to compute
D(s) [−B(s) A(s)] = 0 N (s)
2.1
(9)
Algorithm (Chang and Pearson, 1982)
Define
D(s) F (s) = N (s)
(10)
F (s) = F0 + F1 s + F2 s2 + · · · + Fw sw
(11)
Let where, Fi is the matrix of coefficients of si in the polynomial matrix F(s). It is assumed that the degree of F (s) is w. We want to compute the Modified Minimal Basis E1(s), where E1(s) = [−B(s) A(s)] (12) such that E1(s)F (s) = 0
(13)
Assume that E1(s) is a polynomial matrix of degree v, which is to be determined: E1(s) = E10 + E11 s + E12 s2 + · · · + E1v sv
(14)
Equating the coefficients of powers of s in Eq. 13, we get T1 S = 0
(15)
T 1 = [E10 E11 E12 · · · E1v ]
(16)
where and
S =
F0 F1 · · · Fw 0 0 F0 F1 · · · Fw .. . 0
0
0
···
0
0 0
··· ···
0 0
0 0
F0 F1 · · · Fw
(17)
Since D(s) is nonsingular, the first row of S is nonzero. Let the kth row of F be denoted by fk0 . Find the maximum k such that the first k rows are independent. In this case, let b11 f10 + b12 f20 + · · · + b1k1 fk0 1 + fk0 1 +1 = 0 3
(18)
Then the first row of T 1 is [b11 b12 · · · b1k1 1 0 · · · 0] Since the (k1 + 1)st entry is fixed at 1, the above row is unique. We next proceed to compute the second row of T 1. First of all, one of the first k1 + 1 rows of S has to be deleted to make the remaining k1 rows linearly independent. The row to be deleted is decided as follows: From Eq. 12 and Eq. 16, T 1 = [−B0 A0 − B1 A1 · · · − Bv Av ]
(19)
Define a set of integers in which every integer corresponds to a column of A0 , A1 , · · · in T 1. This set is denoted by a and a = {i : integer, n ≤ (i − 1)(mod q) ≤ n + m − 1}
(20)
where n and m come from the dimensions of N (s) and D(s) and q = m + n: N (s) ∈ Rm×n [s] and D(s) ∈ Rn×n [s]. Choose the largest integer ≤ k1 + 1 and belonging to a. Call this pr(1), primary redundant row. Delete the following rows of S: pr(1), pr(1) + q, pr(1) + 2q, · · ·. that is, delete every qth row starting with pr(1)th. The rows that are deleted will be known as redundant rows. 0 Begin with k = k1 + 1 and test if fk+1 is a linear combination of previous independent rows in S, where S denotes the S matrix with redundant rows delted. Increase k and continue this test until an integer k2 is found such that fk0 2 +1 is a linear combination of the previous rows in S. Then the second row in T 1 can be determined. In this row, the coefficients that multiply the redundant rows and rows > k2 + 1 of S matrix will be zero. The next primary redundant row pr(2) is one of the dependent rows used in the calculation of the second row of T 1. pr(2) is the largest number ≤ k2 + 1 and belonging to a. If pr(2) < pr(1), replace pr(1) with pr(2) and recalculate the second row of T 1. After pr(2) is determined, all redundant rows of S matrix are deleted. This procedure is repeated until all required rows of T 1 are determined. Because of the assumed dimensions for N (s) and D(s), there should be m rows in T 1. From Eq. 12, Eq. 14 and Eq. 16, it is clear that by splitting the T 1 matrix appropriately, we can get −B(s) and A(s).
2.2
Conventions
Kwakernaak’s (1991) convention of writing the coefficient matricies corresponding to ascending powers of s is used in this work. For example,
0 4+s 0 4 0 1 N (s) = = + s −1 8 + 3s −1 8 0 3 4
(21)
will have to be entered in MATLAB as,
0 4 0 1 N = −1 8 0 3
(22)
The second convention is that every polynomial matrix will have two variables: one will have the coefficient matrix and the other the degree of the polynomial matrix. In the above example, for instance, the degree of N (s) is one. Unless this is specified, the number of columns of N (s) cannot be determined. The third convention is that the coefficient matrix will be entered first and then its degree.
2.3
Example: Coprime factorization
In this section we discuss the usage of the program with an example. Let
1 0 0 1 0 0 N (s) = 0 1 0 and D(s) = s 1 0 s s 1 0 0 1 2.3.1
(23)
Input program listing (data01.m)
An m file containing the following statements is executed. format compact format short D = [ 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 1 0] N = [ 1 0 0 0 1 0 0 0 1] degD = 1 degN = 0 [Lnum,degLnum,Lden,degLden] = left_prm(N,degN,D,degD) Notice that there are only four input arguments to the function-call left prm. The symbol Lnum stands for left numerator and similarly Lden stands for left denominator. The prefix deg stands for degree. 5
2.3.2
Output from MATLAB
The following is the resulting output from MATLAB (ex01.out). D = 1 0 0
0 1 0
0 0 1
0 1 1
0 0 1
0 0 0
N = 1 0 0 0 1 0 0 0 1 degD = 1 degN = 0 Lnum = Columns 1 through 7 1.0000 0 0 1.0000 0 0 Columns 8 through 9 0 0 0 0 0 0 degLnum = 2 Lden = 1 0 0 0 1 0 0 0 -1 degLden = 0 2.3.3
0 0 -1.0000
0 -1.0000 1.0000
0 0 1.0000
0 0 0
0 0 -1.0000
Result
For N (s) and D(s) as given in Eq. 23, B(s) and A(s) satisfying Eq. 9 are as given below:
1 0 0 1 0 0 B(s) = 1 0 and A(s) = 0 1 0 −s s − s2 s −1 0 0 −1 6
(24)
2.4
Example: Checking whether a given polynomial matrix is unimodular
Suppose we want to decide whether a given nonsingular matrix D(s) is unimodular. Carry out left coprime factorization as given below: A(s)−1 B(s) = I D(s)−1
(25)
Where I is an identity matrix and A is row proper. It is clear that D is unimodular if and only if A is a constant matrix. This is illustrated with a unimodular D matrix. 2.4.1
Input program listing
The following MATLAB mfile is executed (data02.m). format compact format short D = [1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 1 0] degD = 1 [B,degB,A,degA] = left_prm(eye(3),0,D,degD) if degA == 0, ’Given matrix D is unimodular’ end 2.4.2
Output from MATLAB
The following is the resulting output (ex02.out). D = 1 0 0 0 1 0 0 0 1 degD = 1 B = Columns 1 through 7 1.0000 0 0 1.0000 0 0 Columns 8 through 9
0 1 1
0 0 1
0 0 -1.0000
0 0 0
0 -1.0000 1.0000
7
0 0 1.0000
0 0 0
0 0 -1.0000
0 0 0
0 0 0
degB = 2 A = 1 0 0 0 1 0 0 0 -1 degA = 0 ans = Given matrix D is unimodular
2.5
Example: Producing a row proper polynomial
Given a nonsingular polynomial matrix D(s), we wish to find a unimodular matrix W (s), such that ˆ W (s)D(s) = D(s) (26) ˆ ˆ where D(s) is row proper. This is equivalent to finding a left coprime pair D(s), W (s), such that ˆ −1 W (s) = I D(s)−1 D(s) (27) 2.5.1
Input program listing
The following MATLAB mfile is executed (data03.m). format compact; format short D = [4 0 12 0 13 0 6 0 1 0 2 2 5 1 4 0 1 0 0 0] degD = 4 [W,degW,Dhat,degDhat] = left_prm(eye(2),0,D,degD) 2.5.2
Output from MATLAB
The following is the resulting output (ex03.out). D = 4 2 degD =
0 2
12 5
0 1
13 4
0 0
6 1
8
0 0
1 0
0 0
4 W = -1.0000 2.0000 0 1.0000 degW = 1 Dhat = Columns 1 through 7 0 4.0000 2.0000 2.0000 Column 8 0 0 degDhat = 3
2.6
0 0
1.0000 0
0 5.0000
4.0000 1.0000
0 4.0000
1.0000 0
0 1.0000
Programs
The following programs, whose listings appear in alphabetical order in the appendix, are used in the above-said calculation: 1. left prm.m 2. indep.m 3. makezero.m 4. move.m 5. seshft.m 6. t1calc.m The user starts the calculation by invoking left prm.m. The following routines of Kwakernaak (1990) are also required: 1. clcoef.m 2. colsplit.m 3. polsize.m 4. rowjoin.m The program clcoef.m has been modified in this work and its listing also appears in the appendix. For other routines, the reader is referred to Kwakernaak (1990). 9
3
Aryabhatta’s Identity
In this section, we will find polynomial matrices X(s) and Y (s) satisfying the Aryabhatta’s Identity, X(s)D(s) + Y (s)N (s) = I (28) given coprime polynomial matrices N (s) and D(s) with D(s) column proper.
3.1
Algorithm (Chang and Pearson, 1982)
Given N (s) and D(s) as given above, go through the entire calculation of Sec. 2 to compute T 1 matrix of Eq. 15 and Eq. 16. In this process, left coprime matrices B(s) and A(s) can also be computed without much more effort. As it is given that N (s) and D(s) are coprime with D(s) column proper, there exist X(s) and Y (s) satisfying Eq. 28 with deg[X(s) Y (s)] < deg[−B(s) A(s)]. Let S denote S matrix of Eq. 17 with all redundant rows deleted. Thus S contains only independent rows. Thus it is possible to solve bS = I
(29)
After b is found, it is augmented with zero columns at locations corresponding to the rows of S deleted. Call the matrix thus obtained as T 2. As the polynomial equivalent of this matrix satisfies T 2(s) = [X(s) Y (s)] (30) X(s) and Y (s) can be calculated.
3.2
Usage
We now illustrate how to use this program with an example. Let
0 4+s −s 4s + s2 N (s) = and D(s) = −1 8 + 3s s 0 3.2.1
Input program listing (data04.m)
An m file containing the following statements is executed. format compact format short D = [ 0 0 -1 4 0 1 0 0 1 0 0 0] 10
(31)
N = [ 0 4 0 1 -1 8 0 3 ] degD = 2 degN = 1 [Lnum,degLnum,Lden,degLden,Y,degY,X,degX] = left_prm(N,degN,D,degD,2) Notice that we use the routine left prm.m once again as we did in Sec. 2.3.1. The same naming convention of variables is used. Notice, however, that there are five input arguments used in the call to left prm while only four are required in Sec. 2.3.1. The fifth argument to left prm could be one, two or three. If it is one, coprime factorization is done. If it is two, Aryabhatta’s Identity is solved. Finally, if it is three, it will try to solve Eq. 5. In this case, C(s) also required as an input. This is the topic of discussion in Sec. 4. 3.2.2
Output from MATLAB (ex04.out)
D = 0 0
0 0
-1 1
4 0
0 0
1 0
N = 0 4 0 -1 8 0 degD = 2 degN = 1 Lnum = 1.0000 1.0000 8.0000 4.0000 degLnum = 1 Lden = 0 0 0 0 degLden = 2 Y = 2.0000 -1.0000 0.2500 0
1 3
0 3.0000
0 2.0000
1.0000 0
0 4.0000
0 0
-0.2500 0.0625 11
0 0
0 1.0000
degY = 1 X = 0.7500 -0.1875 degX = 0 3.2.3
0.5000 -0.1250
Result
The results can be summarized as:
1 1 B(s) = 8 + 3s 4 + 2s and
(32)
2 −1 − 0.25s Y (s) = 0.25 0.0625
0.75 0.5 X(s) = −0.1875 −0.125
3.3
s 0 A(s) = 0 4s + s2
(33)
Programs
Same as in Sec. 2.6. The user calls left prm.m.
4
Unilateral polynomial matrix equation
In this section, we will find polynomial matrices X(s) and Y (s) satisfying X(s)D(s) + Y (s)N (s) = C(s)
(34)
given polynomial matrices N (s), D(s) and C(s) with D(s) column proper.
4.1
Algorithm (Chang and Pearson, 1982)
There is a solution to Eq. 34 if and only if the greatest common right divisor of D(s) and N (s) is also a right divisor of C(s). Let B1 (s)A1 (s)−1 be a right coprime factorization of N (s)D(s)−1 , R(s)−1 U1 (s) a left coprime factorization of D(s)−1 A1 (s) and U2 (s)−1 C2 (s) a left coprime factorization of C(s)R(s)−1 . Then Eq. 34 has a solution if and only if U2 (s) is row proper and constant. Once it is determined that a solution exists to Eq. 34, one can solve it using the same technique used for solving Eq. 28, as discussed in Sec. 3.1. That is, we only have to substitue C(s) in the place of I. 12
4.2
Usage
We will illustrate the solution to Eq. 34 with two examples. 4.2.1
First example
An m file containing the following statements is executed (data05.m). format compact format short Num = [0 4 0 1 -1 8 0 3] degNum = 1 Den = [0 0 1 4 0 1 0 0 -1 0 0 0] degDen = 2 C = [1 0 1 1 0 2 0 1] degC = 1 [Lnum,degLnum,Lden,degLden,Y,degY,X,degX] = ... xdync(Num,degNum,Den,degDen,C,degC) and the following MATLAB results are obtained (ex05.out): Num = 0 -1 degNum = 1 Den = 0 0 degDen = 2 C = 1 0 degC = 1 Lnum = 1.0000
4 8
0 0
1 3
0 0
1 -1
4 0
0 2
1 0
1 1
1.0000
0 0
1 0
0
0 13
8.0000 12.0000 degLnum = 1 Lden = 0 0 1 0 0 0 degLden = 2 Y = 2.0000 -1.0000 0.5000 0 degY = 1 X = 1.5000 1.0000 0.3750 0.5000 degX = 0 4.2.2
3.0000
0 4
0 0
0 0
4.0000
0 1
-0.5000 -0.1250
Second example
An m file containing the following statements is executed (data06.m). format compact format short e Num = [0 0.828 72.16 0.556 0 0.23 18.05 0.03 ] degNum = 1 Den = [-1 0 1 0 0 -1 0 1] degDen = 1 C = [4.002778 0.09749997 -3006.672 -95.99581] degC = 0 [Lnum,degLnum,Lden,degLden,Y,degY,X,degX] = ... xdync(Num,degNum,Den,degDen,C,degC) and the following MATLAB results are obtained (ex06.out): Num = 0
8.2800e-001
7.2160e+001 14
5.5600e-001
0 degNum = 1 Den = -1 0 0 -1 degDen = 1 C = 4.0028e+000 -3.0067e+003 degC = 0 Lnum = 0 0 degLnum = 1 Lden = -1.0000e+000 0 degLden = 1 Y = 1.1563e-001 -1.5290e+002 degY = 0 X = -4.0028e+000 3.0067e+003 degX = 0
4.3
2.3000e-001
1.8050e+001
3.0000e-002
8.2800e-001 2.3000e-001
7.2160e+001 1.8050e+001
5.5600e-001 3.0000e-002
0 -1.0000e+000
1.0000e+000 0
0 1.0000e+000
1 0
0 1
9.7500e-002 -9.5996e+001
-2.4049e-001 4.4469e+002
-5.7074e-002 7.1673e+001
Programs
In addition to the programs mentioned in Sec. 2.6, we also need 1. cindep.m 15
2. issoln.m 3. xdync.m The user starts the calculations with xdync.m
5
Generalized Aryabhatta’s Identity
Given matrices as given in Eq. 35, N (s), D(s) not necessarily coprime, D(s) nonsingular, H(s) = N (s)D(s)−1
(35)
find matrices in the following generalized Aryabhatta’s Identity:
A(s) B(s) X(s) −B1 (s) I 0 = −Y1 (s) X1 (s) Y (s) A1 (s) 0 I
(36)
A(s)−1 B(s) = B1 (s)A1 (s)−1 = H(s)
(37)
with
5.1
Algorithm (Chang and Pearson, 1982)
Using the algorithms developed earlier, one can compute the required matrices in three steps: 5.1.1
Step1: Find A(s) and B(s)
Given H(s) = N (s)D(s)−1 find A(s) and B(s) satisfying Eq. 37. This is done using the procedure explained in Sec. 2. A(s) and B(s) are left coprime and A(s) is row proper. 5.1.2
Step2: Find A1 (s), B1 (s), X(s) and Y (s)
Starting from A(s) and B(s) left coprime, A(s) row proper, calculate right coprime A1 (s) and B1 (s) satisfying Eq. 37 with A1 (s) column proper. Also solve the following Aryabhatta’s Identity for X(s) and Y (s): A(s)X(s) + B(s)Y (s) = I
(38)
These calculations are carried out by transposing A(s) and B(s), using the procedure outlined in Sec. 2 and Sec. 3 and transposing the resulting matrices. 16
5.1.3
Step 3: Find X1 (s) and Y1 (s)
Using the procedure outlined in Sec. 3, find X1 (s) and Y1 (s) satisfying the following Aryabhatta’s idenity: X1 (s)A1 (s) + Y1 (s)B1 (s) = I
5.2
(39)
Usage
We will illustrate the solution to Eq. 36 with two examples. 5.2.1
First example
An m file containing the following statements is executed (data07.m). format compact format short e Num = [361 72.3 .2 -17.95 0 0 5.2 .18 2.88 .03 .46 0] degNum = 2 Den = [10 0 6 0 1 0 0 10 0 6 0 1] degDen = 2 [A,degA,B,degB,A1,degA1,B1,degB1,X,degX,Y,degY,X1,degX1,Y1,degY1] = ... arya(Num,degNum,Den,degDen) and the following MATLAB results are obtained (ex07.out): Num = 3.6100e+002 7.2300e+001 5.2000e+000 1.8000e-001 degNum = 2 Den = 10 0 6 0 0 10 0 6 degDen = 2 A = 5.0028e+000 -3.0067e+003 1.6667e-003 9.9722e-001 degA =
2.0000e-001 -1.7950e+001 2.8800e+000 3.0000e-002
1 0
0 1
1.0000e+000 0
17
0 1.0000e+000
0 4.6000e-001
0 0
1 B = -1.3829e+003 5.7872e-001 degB = 1 A1 = -4.0000e+000 2.0000e+001 degA1 = 1 B1 = 2.0000e-001 -1.7200e+000 degB1 = 1 X = 0 -6.3889e-003 degX = 0 Y = 1.3889e-002 -5.5556e-002 degY = 0 X1 = -3.8227e+000 -4.2593e-002 degX1 = 0 Y1 = 1.3889e-002 -5.5556e-002 degY1 = 0
-1.7950e+001 3.0000e-002
0 4.6000e-001
0 0
-2.5000e+000 1.0000e+001
1.0000e+000 0
0 1.0000e+000
-1.7950e+001 -1.1200e+000
0 4.6000e-001
0 0
0 -3.8227e+000
8.3102e+000 9.2593e-002
0 0
8.3102e+000 9.2593e-002
18
5.2.2
Second example
An m file containing the following statements is executed (data08.m). format compact format short e Num = [ 675 90 70 100 720 228 139 185 282 192 90 108 48 60 23 25 3 6 2 2 16 40 200 128 28 78 130 160 14 49 28 64 2 12 2 8 0 1 0 0 288 0 40 544 328 -80 78 840 136 -76 49 472 26 -22 12 114 2 -2 1 10] Den = [ 120 0 0 0 274 0 0 0 225 0 0 0 85 0 0 0 15 0 0 0 1 0 120 0 0 0 274 0 0 0 225 0 0 0 85 0 0 0 15 0 0 0 0 0 120 0 0 0 274 0 0 0 225 0 0 0 85 0 0 0 15 0 0 0 0 0 120 0 0 0 274 0 0 0 225 0 0 0 85 0 0 0 15 0 degNum = 4 degDen = 5 [A,degA,B,degB,A1,degA1,B1,degB1,X,degX,Y,degY,X1,degX1,Y1,degY1] = ... arya(Num,degNum,Den,degDen) and the following MATLAB results are obtained (ex08.out): Num = Columns 1 through 12 675 90 70 100 16 40 200 128 288 0 40 544 Columns 13 through 20 48 60 23 25 2 12 2 8 26 -22 12 114 Den = Columns 1 through 12 120 0 0 0 0 120 0 0 0 0 120 0 0 0 0 120 Columns 13 through 24 85 0 0 0 0 85 0 0 0 0 85 0
720 28 328
228 78 -80
139 130 78
185 160 840
3 0 2
6 1 -2
2 0 1
2 0 10
274 0 0 0
0 274 0 0
0 0 274 0
15 0 0
0 15 0
0 0 15
19
282 14 136
192 49 -76
90 28 49
108 64 472
0 0 0 274
225 0 0 0
0 225 0 0
0 0 225 0
0 0 0 225
0 0 0
1 0 0
0 1 0
0 0 1
0 0 0
0 1 0 0
0 0 1 0
0 0 0 1]
0 0 0 85 degNum = 4 degDen = 5 A = Columns 1 through 6 8.0000e+000 -8.5714e-001 0 6.0000e+000 0 0 Columns 7 through 12 7.0000e+000 -4.2857e-001 0 6.0000e+000 0 0 degA = 3 B = Columns 1 through 6 4.3429e+001 5.7143e+000 -1.0000e+001 2.0000e+000 3.6000e+001 0 Columns 7 through 12 6.7500e+000 6.5000e+000 5.0000e-001 -7.0000e+000 6.0000e+000 5.4000e+001 degB = 2 A1 = Columns 1 through 6 -2.3745e+000 3.6943e+000 3.5090e+000 3.8856e+000 -5.7623e-002 2.4658e+000 1.8727e-001 -5.1381e-001 Columns 7 through 12 -1.0265e+001 2.1147e+001 -2.5916e+000 2.4436e+000 -6.7107e-001 6.0864e-001 5.6777e+000 -1.5216e+000
0
0
0
15
0
0
0
1
-6.0714e-001 -4.5000e+000 1.5000e+001
1.4000e+001 -1.2857e+000 -8.5714e-001 0 1.1000e+001 -6.0000e+000 0 0 2.3000e+001
-2.5000e-001 -1.5000e+000 9.0000e+000
1.0000e+000 0 0
0 1.0000e+000 0
0 0 1.0000e+000
3.0357e+000 3.0000e+000 2.3500e+001 1.2071e+001 8.5000e+000 -1.4000e+001 -1.0000e+000 6.0000e+000 5.0000e+000 6.8000e+001 1.4000e+001 -1.0000e+001 3.0000e+000 6.0000e+000 0 1.0000e+000 2.0000e+000 -2.0000e+000
2.0000e+000 0 1.0000e+000
2.0000e+000 0 1.0000e+001
-8.0572e+000 1.3912e+001 -2.8235e+000 -1.0644e+001 9.7473e+000 4.8547e+000 -1.3421e+000 1.2173e+000 -2.8812e-002 7.3619e+000 -3.9562e+000 7.2029e-002
4.8235e+000 1.0908e+000 3.2329e+000 4.1777e-001
-4.4898e-001 1.0000e+000 0 0
8.2347e+000 0 0 0
20
1.1293e+000 -2.2075e+000 0 0 1.0000e+000 0 0 1.0000e+000
Columns 13 through 16 0 0 0 0 0 0 0 0 degA1 = 3 B1 = Columns 1 through 6 -1.0603e+001 2.4705e+001 9.5678e-001 5.3493e+000 -4.8691e+000 7.3589e+000 Columns 7 through 12 -4.6224e+000 2.7704e+001 0 2.0000e+000 5.5850e+000 1.2469e+001 degB1 = 2 X = 1.0422e-001 6.7621e-001 1.4550e-002 6.0859e-002 7.3995e-001 1.6999e-001 degX = 1 Y = Columns 1 through 6 -8.0407e-003 -1.1722e-001 2.2981e-001 -7.9226e-002 5.0045e-002 7.6593e-002 -1.6265e-001 1.8929e-002 Columns 7 through 9 -3.4545e-002 -2.4430e-002 0 0 0 0 0 0 degY = 2 X1 =
0 0 0 0
-4.7953e+001 9.9340e-001 1.3589e+001
1.0000e+000 0 0 0
8.2981e+001 4.6531e+000 2.9130e+000 1.0000e+000 1.5861e+001 -2.8980e+000
0 0 0
0 0 0
4.1309e-001 2.5528e-002 -2.7790e-001
1.0364e-001 0 6.9090e-002
0 0 0
5.3878e+000 0 3.2585e+000 3.0000e+000 0 2.0000e+000
7.3289e-002 -8.5167e-003 0 0 4.8859e-002 -5.6778e-003
-6.7598e-002 -8.4252e-002 -1.5058e-001 -6.9968e-002 -1.3647e-001 5.4541e-002 -1.2000e-002 -3.1206e-002 -2.5357e-002 2.5023e-002 -4.5037e-002 -5.4345e-002 1.1366e-001 -6.2556e-002 5.4491e-003 4.2113e-002 2.8389e-003 0 0 0
21
Columns 1 through 6 -7.8991e-001 1.9245e-001 -7.3473e-002 -1.6233e-001 7.0154e-001 2.2725e-001 4.7862e-001 2.2771e-001 Columns 7 through 8 -7.7875e-002 2.0298e-001 4.3002e-003 4.9341e-001 8.3000e-002 -2.9602e-001 6.6251e-002 4.0701e-002 degX1 = 1 Y1 = Columns 1 through 6 8.3183e-002 -1.1490e-001 1.0534e-001 2.2385e-001 -2.6336e-001 -2.3916e-002 -1.7092e-001 -1.4296e-001 Columns 7 through 9 5.4541e-002 -1.2000e-002 2.5023e-002 -4.5037e-002 -6.2556e-002 5.4491e-003 -3.4545e-002 -2.4430e-002 degY1 = 2
5.3
-7.1474e-002 -2.3854e-001 -1.0121e-001 -3.7766e-001 1.0418e-001 7.9751e-001 3.3623e-002 -2.1379e-001 1.1862e-002 -1.1188e+000 1.0344e-001 4.5411e-001 6.4675e-002 -6.8624e-001 9.7957e-002 2.3738e-001
1.0650e-001 2.4181e-001 6.6016e-003 -9.9980e-002 -2.3711e-001 1.2492e-001 -4.0572e-002 -2.5184e-001 3.4724e-001 -3.1231e-001 3.0003e-002 2.9031e-001 2.4762e-001 -1.8346e-001 -2.3686e-002 1.1781e-001 -3.1206e-002 -5.4345e-002 4.2113e-002 2.8389e-003
Programs
In addition to the programs mentioned in Sec. 2.6, we also need arya.m and transp.m developed by Kwakernaak (1990). The calculations are started by executing arya.m.
6
Bilateral polynomial matrix equation
In this section, we will find polynomial matrices X(s) and Y (s) satisfying X(s)D(s) + N (s)Y (s) = C(s)
(40)
given polynomial matrices N (s), D(s) and C(s) with D(s) column proper and the following dimensions: N (s) ∈ Rm×h [s], D(s) ∈ Rn×n [s] and C(s) ∈ Rm×n [s]. 22
6.1
Algorithm (Chang and Pearson, 1982)
Let x0k , yk0 and c0k be the kth row vectors of X(s), Y (s) and C(s) respectively, i.e. x0k = [xk1 xk2 . . . xkn ]
k = 1, . . . , m
(41)
yk0 = [yk1 yk2 . . . ykn ]
k = 1, . . . , h
(42)
c0k = [ck1 ck2 . . . ckn ]
k = 1, . . . , m
(43)
where xkj is the element of X(s) at k-th row and j-th column. ykj and ckj are defined in a similar way. Then Eq. 40 can be transformed to ˜ D(s) ˜ ˜ (s) = C(s) ˜ X(s) + Y˜ (s)N
(44)
with the following definitions: ˜ = [x0 x0 . . . x0 ] X 1 2 m 0 0 Y˜ = [y1 y2 . . . yh0 ] C˜ = [c01 c02 . . . c0m ]
(45)
˜ = Im ⊗ D D ˜ = N 0 ⊗ In N
(48)
(46) (47)
(49)
where ⊗ denotes Kronecker product. Now Eq. 44 is of the form Eq. 34. Thus the algorithm used in Sec. 4 can be used for this purpose.
6.2
Usage
We will illustrate the solution to Eq. 40 with two examples. 6.2.1
First example
An m file containing the following statements is executed (data09.m). format compact format short Num = [-16 8 0 4 -4 0 0 1] degNum = 1 Den = [0 0 -1 4 0 1 0 0 1 0 0 0] degDen = 2 C = [1 0 1 1 23
0 2 0 1] degC = 1 [Y,degY,X,degX] = xdnyc(Num,degNum,Den,degDen,C,degC) and the following MATLAB results are obtained (ex09.out): Num = -16 -4 degNum = 1 Den = 0 0 degDen = 2 C = 1 0 degC = 1 Y = 0 0.1250 degY = 1 X = 1.5000 0.3750 degX = 0 6.2.2
8 0
0 0
4 1
0 0
-1 1
4 0
0 2
1 0
1 1
-0.5000 -1.0000
0 0
0 0
1 0
-0.1250 -0.3750
2.0000 0.2500
Second example
An m file containing the following statements is executed (data10.m). format compact format short Num = [ 1 0 1 1] 24
degNum = 0 Den = [ 1 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 -2 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 -1 0 0 0 0 0] degDen = 2 C = [ 0 0 0 -3 0 1 0 0 2 0 0 0 0 0 -1 0 0 0 0 0] degC = 1 [Y,degY,X,degX] = xdnyc(Num,degNum,Den,degDen,C,degC) and the following MATLAB results are obtained (ex10.out): Num = 1 0 1 1 degNum = 0 Den = Columns 1 through 12 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 Columns 13 through 15 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 degDen = 2 C = 0 0 0 -3 0 0 0 0 degC =
0 0 0 0 1
-1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 -2 0
0 0 0 0 -1
0 -1
1 0
0 0
0 0
2 0
0 0
25
0 0 0 0 0
0 0 0 0 0
1 Y = Columns 1 through 7 1.0000 0 -1.0000 0 Columns 8 through 10 0 2.0000 0 -2.0000 degY = 1 X = -1.0000 0 0 0 degX = 0
6.3
0 0
-3.0000 3.0000
0 -1.0000
0 0
0 0
0 0
0 0
0 0
0 0
Programs
In addition to the programs mentioned in Sec. 2.6, we also need the following: 1. flat2nor.m 2. nor2flat.m 3. polksca.m 4. scakpol.m 5. xdync.m and transp.m developed by Kwakernaak (1990). The user initiates the calculations with xdync.m.
7
Numerical issues
The most crucial step in computing coprime factorization is the determination of linear dependence. We have used the singular values to detect the occurrence of linear dependence. We also use a zeroing strategy to make small terms zero. 26
7.1
Linear dependence
Suppose we want to check whether the mth row of an m × n matrix A is dependent on the previous m − 1 rows. It is assumed that the first m − 1 rows are linearly independent. Compute the singular values of A. Let σ be the maximum and σ be the minimum of these. If σ/σ < ε × max(m, n) then mth row is dependent on the rest. Here ε is the machine epsilon. Suppose the above condition is violated. Then we carry out the following test to confirm that the rows are independent. Let the singular values be arranged in descending order. If the ratio of the successive singular values is larger than a large number G, we take the rows to be independent. In our calculations, we have taken the default value of G to be 108 , but the user can override it. This is implemented in the routines that check independence, namely indep.m, Sec. A.5 and cindep.m, Sec. A.2.
7.2
Zeroing small entries
Small entries of a vector are made zero with the procedure as suggested by Chang, (1982). The absolute values of the vector are arranged in descending order. If the ratio of two successive entries is greater than a large number G, we zero all succeeding entries, starting from the smaller of the two. We have chosen this large number to the same as the one discussed in the previous sub-section. This is implemented in Sec. A.9.
27
A
MATLAB routines
All the m files developed in this work are listed in this section. These are listed under the heading local routines. We have listed two routines from the work of Kwakernaak (1990) because we have modified them in the current work. These are clcoef.m and l2r.m. In the following, we also list the names of functions called by each routine. We have also listed the functions that came with MATLAB. These have been listed under the heading Routines of mathworks.
A.1
arya.m
A.1.1
Purpose
Used to solve generalized Aryabhatta’s Identity, Eq. 36. A.1.2
mfiles called
Local routines: left prm. Kwakernaak’s routines: transp. A.1.3
Listing of the code
% function .. % [A,degA,B,degB,A1,degA1,B1,degB1,X,degX,Y,degY,X1,degX1,Y1,degY1] ... % = arya(N,degN,D,degD) % calculates the entries of generalized aryabhatta identity % -1 % given H = N * D not necessarily coprime, % finds A, B, A1, B1, X, Y, X1 and Y1 such that V * W = I, where % % ( A B ) ( X -B1 ) % V = ( ) and W = ( ) % ( -Y1 X1 ) ( Y A1 ) % -1 -1 % and H = A * B = B1 * A1 , A, B left coprime and B1, A1 right coprime % function [A,degA,B,degB,A1,degA1,B1,degB1,X,degX,Y,degY,X1,degX1,Y1,degY1] ... = arya(N,degN,D,degD,gap) if nargin==4 gap = 1.0e8; 28
end [B,degB,A,degA] = left_prm(N,degN,D,degD,1,gap); [A,degA] = transp(A,degA); [B,degB] = transp(B,degB); [B1,degB1,A1,degA1,Y,degY,X,degX] = left_prm(B,degB,A,degA,2,gap); [B1,degB1] = transp(B1,degB1); [A1,degA1] = transp(A1,degA1); [X,degX] = transp(X,degX); [Y,degY] = transp(Y,degY); [B,degB,A,degA,Y1,degY1,X1,degX1] = left_prm(B1,degB1,A1,degA1,2,gap);
A.2 A.2.1
cindep.m Purpose
Checks if the last row of a matrix is dependent on the previous rows and if so, returns the coefficients of dependence. If independent, the coefficients will be null. See Sec. 7.1. A.2.2
mfiles called
Local routines: makezero. Routines of mathworks: norm, svd, /. A.2.3
Listing of the code
% function b = cindep( S,gap) % used in XD + YN = C. all rows except the last of are assumed to % be independent. The aim is to check if the last row is dependent on the % rest and if so how. The coefficients of dependence is sent in b function b = cindep( S,gap) if nargin == 1 gap = 1.0e8; end [rows,cols] = size(S); if rows > cols ind = 0; else sigma = svd(S); 29
len = length(sigma); if (sigma(len)/sigma(1) =gap) ind = 0; % not dependent else ind = 1; % independent end end end if ind b = []; else b = S(rows,:)/S(1:rows-1,:); b = makezero(b,gap); end
A.3
clcoef.m
A.3.1
Purpose
Used to clear trailing zeros. A.3.2
mfiles called
Kwakernaak’s routines: polsize. Routines of mathworks: norm, all. A.3.3
Listing of the code
% function [P,degP] = clcoef(Q,degQ) % MATLAB FUNCTION clcoef TO CLEAR ZERO LEADING % COEFFICIENT MATRICES OF A POLYNOMIAL MATRIX % H. Kwakernaak, July, 1990 % Modified by Kannan Moudgalya in Nov. 1992 function [P,degP] = clcoef(Q,degQ)
30
[rQ,cQ] = polsize(Q,degQ); if all(all(Q==0)) P = zeros(rQ,cQ); degP = 0; else P = Q; degP = degQ; rP = rQ; cP = cQ; j = degP+1; while j >= 0 if norm(P(:,(j-1)*cP+1:j*cP),inf) < (1e-8)*norm(P,inf) P = P(:,1:(j-1)*cP); degP = degP-1; else j = 0; end j = j-1; end end
A.4 A.4.1
flat2nor.m Purpose
Rearranges a flat (row) polynomial into a polynomial matrix. Opposite of what nor2flat, Sec. A.11 does. A.4.2
mfiles called
Routines of mathworks: error. A.4.3
Listing of the code
% function [X,degX] = flat2nor(flatX,degflatX,rows,bcols) % returns a flat polynomial X into a polynomial of size rows by bcols function [X,degX] = flat2nor(flatX,degflatX,rows,bcols) if length(flatX) == rows * bcols * (degflatX+1) degX = degflatX; X = []; for i = 1:degX+1 31
dummy = zeros(bcols,rows); dummy(:) = flatX( (i-1)*rows*bcols+1 : i*rows*bcols ); dummy = dummy’; X = [X dummy]; end else error(’flat2nor: dimensions do not agree’) end
A.5
indep.m
A.5.1
Purpose
Used to check if the rows of a matrix are dependent. If they are dependent, the coefficients that relate the first dependent row on the previous rows are returned. If the input matrix is an independent matrix, the coefficient vector will be null. See Sec. 7.1. A.5.2
mfiles called
Local routines: makezero. Routines of mathworks: norm, /. A.5.3
Listing of the code
% function b = indep(S,gap) % determines the first row that is dependent on the previous rows of S. % The coefficients of dependence is returned in b function b = indep( S,gap) if nargin == 1 gap = 1.0e8; end [rows,cols] = size(S); ind = 1; i = 2; while ind & i gap) ind = 0; else ind = 1; i = i+1; end end end if ind b =[]; else c = S(i,:)/S(1:i-1,:); c = makezero(c,gap); b = [-c 1]; end
A.6
issoln.m
A.6.1
Purpose
Performs the computations indicated in the beginning of Sec. 4.1 and decides whether there is a solution to Eq. 34. A.6.2
mfiles called
Local routines: arya. Kwakernaak’s routines: modified version of l2r. A.6.3
Listing of the code
% function soln = issoln(D,degD,C,degC,B,degB,A,degA) % finds out if there is a solution to the system XD + YN = C % [-B A] is the left modified minimal basis of [D’ N’]’ function soln = issoln(D,degD,C,degC,B,degB,A,degA) [B1,degB1,A1,degA1] = l2r(B,degB,A,degA); [U1,degU1,R,degR] = l2r(A1,degA1,D,degD); [C2,degC2,U2,degU2] = left_prm(C,degC,R,degR); if degU2 == 0 33
soln = 1; else soln = 0; end
A.7 A.7.1
l2r.m Purpose
Carry out left to right coprime factorization. This is a modified version of Kwakernaak’s routine. A.7.2
mfiles called
Local routines: arya. Kwakernaak’s routines: transp. A.7.3
Listing of the code
% function [Rnum,Rnumdeg,Rden,Rdendeg] = l2r(N,degN,D,degD) % given Numerator and Denominator polynomial matrices in left form, % not necessarily coprime, finds right coprime factorisation. function [Rnum,Rnumdeg,Rden,Rdendeg] = l2r(N,degN,D,degD) [N,degN] = transp(N,degN); [D,degD] = transp(D,degD); [Rnum,Rnumdeg,Rden,Rdendeg] = left_prm(N,degN,D,degD); [Rnum,Rnumdeg] = transp(Rnum,Rnumdeg); [Rden,Rdendeg] = transp(Rden,Rdendeg);
A.8 A.8.1
left prm.m Purpose
Used to produce left coprime factorization given arbitrary right factorization. Used in all the computations listed in this report. A.8.2
mfiles called
Local routines: t1calc. 34
Kwakernaak’s routines: rowjoin, polsize, colsplit, clcoef. The last routine has been modified locally. Routines of mathworks: nargin, isempty, size, round. A.8.3 % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
Listing of the code
function [B,degB,A,degA,Y,degY,X,degX] = ... left_prm(N,degN,D,degD,job,gap) does three different things according to integers that ’job’ takes job = 1. this is the default. It is always done for all jobs. -1 -1 -1 Given ND , returns coprime B and A where ND = A B It is enough if one sends the first four input arguments If gap is required to be sent, then one can send either 1 or a null entry for job job = 2. first solve for job = 1 and then solve XA + YB = I job = 3. used in solving XD + YN = C after finding coprime factorization, data are returned convention: the variable with prefix deg stand for degrees of the corresponding polynomial matrices input: N: right fraction numerator polynomial matrix D: right fraction denominator polynomial matrix N and D are not neccessarily coprime gap: variable used to zero entries; default value is 1.0e+8 output b and A are left coprime num. and den. polynomial matrices X and Y are solutions to Aryabhatta identity, only for job = 2
function [B,degB,A,degA,Y,degY,X,degX] = ... left_prm(N,degN,D,degD,job,gap) 35
if nargin == 4 | nargin == 5 gap = 1.0e8 ; end if nargin == 4, job = 1; end [F,degF] = rowjoin(D,degD,N,degN); [Frows,Fbcols] = polsize(F,degF); % Fbcols = block columns Fcols = Fbcols * (degF+1) ; % actual columns of F T1 = [];pr =[];degT1 = 0; T1rows = 0;shft = 0; S=F; sel = ones(Frows,1); T1bcols =1; abar = (Fbcols + 1):Frows; % a_super_bar of B-C.Chang while isempty(T1) | T1rows < Frows - Fbcols Srows = Frows*T1bcols; % max actual columns of result [T1,T1rows,sel,pr] = ... t1calc(S,Srows,T1,T1rows,sel,pr,Frows,Fbcols,abar,gap); [T1rows,T1cols] = size(T1); if T1rows < Frows - Fbcols T1 = [T1 zeros(T1rows,Frows)]; T1bcols = T1bcols + 1; % max. block columns of result degT1 = degT1 + 1; %degree of result shft = shft +Fbcols; S = seshft(S,F,shft); sel = [sel;sel(Srows-Frows+1:Srows)]; rowvec = (T1bcols-1)*Frows+(Fbcols+1):T1bcols * Frows; abar = [abar rowvec]; % A_super_bar of B-C.chang end end [B,degB,A,degA] = colsplit(T1,degT1,Fbcols,Frows-Fbcols); [B,degB] = clcoef(B,degB); B = -B; [A,degA] = clcoef(A,degA); if job == 2 S = S(sel,:); % columns [redSrows,Scols] = size(S); C = [eye(Fbcols) zeros(Fbcols,Scols-Fbcols)]; % append with zeros T2 = C/S; T2 = makezero(T2,gap); T2 = move(T2,find(sel),Srows);
36
[X,degX,Y,degY] = colsplit(T2,degT1,Fbcols,Frows - Fbcols); [X,degX] = clcoef(X,degX); [Y,degY] = clcoef(Y,degY); elseif job == 3 Y = S; degY = sel; X = degT1; degX = Fbcols; else if job ~= 1 error(’Message from left_prm:no legal job number specified’) end end
A.9 A.9.1
makezero.m Purpose
Reduces small entries to zeros. See Sec. 7.2. A.9.2
mfiles called
Routines of mathworks: find, norm. A.9.3
Listing of the code
% function B = makezero(B,gap) % where B is a vector and gap acts as a tolerance function B = makezero(B,gap) if nargin == 1 gap = 1.0e8; end temp = B(find(B)); % non zero entries of B temp = -sort(-abs(temp)); % absolute values sorted in descending order len = length(temp); ratio = temp(1:len-1) ./temp(2:len); % each ratio >1 min_ind = min(find(ratio>gap)); our_eps = temp(min_ind+1); 37
zeroind = find(abs(B)= 0 B = [zeros(Brows,N) B]; Bcols = Bcols + N; elseif N < 0 A = [zeros(Arows,abs(N)) A]; Acols = Acols +abs(N); end if Acols < Bcols A = [A zeros(Arows,Bcols-Acols)]; elseif Acols > Bcols B = [B zeros(Brows,Acols-Bcols)]; end C = [A B];
A.15
t1calc.m
A.15.1
Purpose
Calculates rows of T 1 matrix as discussed in Sec. 2.1. A.15.2
mfiles called
Local routines: indep, mod Routines of mathworks: norm, isempty, any, A.15.3
Listing of the code
% function [T1,T1rows,sel,pr] = ... % t1calc(S,Srows,T1,T1rows,sel,pr,Frows,Fbcols,abar,gap) % calculates the coefficient matrix T1 41
% redundant row information is kept in sel: redundant rows are marked % with zeros. The undeleted rows are marked with ones. function [T1,T1rows,sel,pr] = ... t1calc(S,Srows,T1,T1rows,sel,pr,Frows,Fbcols,abar,gap) b = 1; % vector of primary red.rows while (T1rows < Frows - Fbcols) & any(sel==1) & ~isempty(b) b = indep( S(sel,:),gap); % send selected rows of S if ~isempty(b) b = move(b,find(sel),Srows); j = length(b); while ~(b(j) & any(abar==j)) % pick largest nonzero entry j = j-1; % of coeff. belonging to abar if ~j fprintf(’\nMessage from t1calc, called from left_prm\n\n’) error(’Denominator is noninvertible’) end end if ~any(j