<HTML>
<HEAD><TITLE>UD01CD - SLICOT Library Routine Documentation</TITLE>
</HEAD>
<BODY>
<H2><A Name="UD01CD">UD01CD</A></H2>
<H3>
Reading a sparse matrix polynomial
</H3>
<A HREF ="#Specification"><B>[Specification]</B></A>
<A HREF ="#Arguments"><B>[Arguments]</B></A>
<A HREF ="#Method"><B>[Method]</B></A>
<A HREF ="#References"><B>[References]</B></A>
<A HREF ="#Comments"><B>[Comments]</B></A>
<A HREF ="#Example"><B>[Example]</B></A>
<P>
<B><FONT SIZE="+1">Purpose</FONT></B>
<PRE>
To read the elements of a sparse matrix polynomial
dp-1 dp
P(s) = P(0) + P(1) * s + . . . + P(dp-1) * s + P(dp) * s .
</PRE>
<A name="Specification"><B><FONT SIZE="+1">Specification</FONT></B></A>
<PRE>
SUBROUTINE UD01CD( MP, NP, DP, NIN, P, LDP1, LDP2, INFO )
C .. Scalar Arguments ..
INTEGER DP, INFO, LDP1, LDP2, MP, NP, NIN
C .. Array Arguments ..
DOUBLE PRECISION P(LDP1,LDP2,*)
</PRE>
<A name="Arguments"><B><FONT SIZE="+1">Arguments</FONT></B></A>
<P>
</PRE>
<B>Input/Output Parameters</B>
<PRE>
MP (input) INTEGER
The number of rows of the matrix polynomial P(s).
MP >= 1.
NP (input) INTEGER
The number of columns of the matrix polynomial P(s).
NP >= 1.
DP (input) INTEGER
The degree of the matrix polynomial P(s). DP >= 0.
NIN (input) INTEGER
The input channel from which the elements of P(s) are
read. NIN >= 0.
P (output) DOUBLE PRECISION array, dimension
(LDP1,LDP2,DP+1)
The leading MP-by-NP-by-(DP+1) part of this array contains
the coefficients of the matrix polynomial P(s).
Specifically, P(i,j,k) contains the coefficient of
s**(k-1) of the polynomial which is the (i,j)-th element
of P(s), where i = 1,2,...,MP, j = 1,2,...,NP and
k = 1,2,...,DP+1.
The not assigned elements are set to zero.
LDP1 INTEGER
The leading dimension of array P. LDP1 >= MP.
LDP2 INTEGER
The second dimension of array P. LDP2 >= NP.
</PRE>
<B>Error Indicator</B>
<PRE>
INFO INTEGER
= 0: successful exit;
< 0: if INFO = -i, the i-th argument had an illegal
value;
= 1 : if a row index i is read with i < 1 or i > MP or
a column index j is read with j < 1 or j > NP or
a coefficient degree d is read with d < 0 or
d > DP + 1. This is a warning.
</PRE>
<A name="Method"><B><FONT SIZE="+1">Method</FONT></B></A>
<PRE>
First, the elements P(i,j,k) with 1 <= i <= MP, 1 <= j <= NP and
1 <= k <= DP + 1 are set to zero. Next the nonzero (polynomial)
elements are read from the input file NIN. Each nonzero element is
given by the values i, j, d, P(i,j,k), k = 1, ..., d+1, where d is
the degree and P(i,j,k) is the coefficient of s**(k-1) in the
(i,j)-th element of P(s), i.e., let
d
P (s) = P (0) + P (1) * s + . . . + P (d) * s
i,j i,j i,j i,j
be the nonzero (i,j)-th element of the matrix polynomial P(s).
Then P(i,j,k) corresponds to coefficient P (k-1), k = 1,...,d+1.
i,j
For each nonzero element, the values i, j, and d are read as one
record of the file NIN, and the values P(i,j,k), k = 1,...,d+1,
are read as the following record.
The routine terminates after the last line has been read.
</PRE>
<A name="References"><B><FONT SIZE="+1">References</FONT></B></A>
<PRE>
None.
</PRE>
<A name="Numerical Aspects"><B><FONT SIZE="+1">Numerical Aspects</FONT></B></A>
<PRE>
None.
</PRE>
<A name="Comments"><B><FONT SIZE="+1">Further Comments</FONT></B></A>
<PRE>
None
</PRE>
<A name="Example"><B><FONT SIZE="+1">Example</FONT></B></A>
<P>
<B>Program Text</B>
<PRE>
* UD01CD EXAMPLE PROGRAM TEXT
*
* .. Parameters ..
INTEGER NIN, NOUT
PARAMETER ( NIN = 5, NOUT = 6 )
INTEGER MPMAX, NPMAX, DPMAX
PARAMETER ( MPMAX = 10, NPMAX = 10, DPMAX = 5 )
INTEGER LDP1, LDP2
PARAMETER ( LDP1 = MPMAX, LDP2 = NPMAX )
* .. Local Scalars ..
INTEGER DP, INFO, INFO1, L, MP, NP
* .. Local Arrays ..
DOUBLE PRECISION P(LDP1,LDP2,DPMAX)
* .. External Subroutines ..
EXTERNAL UD01CD, UD01ND
* .. Executable Statements ..
*
WRITE ( NOUT, FMT = 99999 )
* Skip the heading in the data file and read the data.
READ ( NIN, FMT = '()' )
READ ( NIN, FMT = * ) MP, NP, DP
IF ( MP.LE.0 .OR. MP.GT.MPMAX ) THEN
WRITE ( NOUT, FMT = 99994 ) MP
ELSE IF ( NP.LE.0 .OR. NP.GT.NPMAX ) THEN
WRITE ( NOUT, FMT = 99995 ) NP
ELSE IF ( DP.LT.0 .OR. DP.GT.DPMAX ) THEN
WRITE ( NOUT, FMT = 99993 ) DP
ELSE
* Read the coefficients of the matrix polynomial P(s).
CALL UD01CD( MP, NP, DP, NIN, P, LDP1, LDP2, INFO )
IF ( INFO.GE.0 ) THEN
WRITE ( NOUT, 99996 ) MP, NP, DP
* Write the coefficients of the matrix polynomial P(s).
L = 5
CALL UD01ND( MP, NP, DP, L, NOUT, P, LDP1, LDP2, ' P',
$ INFO1 )
IF ( INFO1.NE.0 )
$ WRITE ( NOUT, FMT = 99997 ) INFO1
END IF
IF ( INFO.NE.0 )
$ WRITE ( NOUT, FMT = 99998 ) INFO
END IF
STOP
*
99999 FORMAT (' UD01CD EXAMPLE PROGRAM RESULTS', /1X)
99998 FORMAT (' INFO on exit from UD01CD = ',I2)
99997 FORMAT (' INFO on exit from UD01ND = ',I2)
99996 FORMAT (' MP =', I2, 2X, ' NP =', I2, 3X, 'DP =', I2)
99995 FORMAT (/' NP is out of range.',/' NP = ',I5)
99994 FORMAT (/' MP is out of range.',/' MP = ',I5)
99993 FORMAT (/' DP is out of range.',/' DP = ',I5)
END
</PRE>
<B>Program Data</B>
<PRE>
UD01CD EXAMPLE PROGRAM DATA
4 3 2
1 1 1
1.0 1.0
2 2 2
2.0 0.0 1.0
3 3 2
0.0 3.0 1.0
4 1 0
4.0
</PRE>
<B>Program Results</B>
<PRE>
UD01CD EXAMPLE PROGRAM RESULTS
MP = 4 NP = 3 DP = 2
P( 0) ( 4X 3)
1 2 3
1 0.1000000D+01 0.0000000D+00 0.0000000D+00
2 0.0000000D+00 0.2000000D+01 0.0000000D+00
3 0.0000000D+00 0.0000000D+00 0.0000000D+00
4 0.4000000D+01 0.0000000D+00 0.0000000D+00
P( 1) ( 4X 3)
1 2 3
1 0.1000000D+01 0.0000000D+00 0.0000000D+00
2 0.0000000D+00 0.0000000D+00 0.0000000D+00
3 0.0000000D+00 0.0000000D+00 0.3000000D+01
4 0.0000000D+00 0.0000000D+00 0.0000000D+00
P( 2) ( 4X 3)
1 2 3
1 0.0000000D+00 0.0000000D+00 0.0000000D+00
2 0.0000000D+00 0.1000000D+01 0.0000000D+00
3 0.0000000D+00 0.0000000D+00 0.1000000D+01
4 0.0000000D+00 0.0000000D+00 0.0000000D+00
</PRE>
<HR>
<p>
<A HREF=..\libindex.html><B>Return to index</B></A></BODY>
</HTML>