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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
|
<HTML>
<HEAD><TITLE>FD01AD - SLICOT Library Routine Documentation</TITLE>
</HEAD>
<BODY>
<H2><A Name="FD01AD">FD01AD</A></H2>
<H3>
Fast recursive least-squares filtering
</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 solve the least-squares filtering problem recursively in time.
Each subroutine call implements one time update of the solution.
The algorithm uses a fast QR-decomposition based approach.
</PRE>
<A name="Specification"><B><FONT SIZE="+1">Specification</FONT></B></A>
<PRE>
SUBROUTINE FD01AD( JP, L, LAMBDA, XIN, YIN, EFOR, XF, EPSBCK,
$ CTETA, STETA, YQ, EPOS, EOUT, SALPH, IWARN,
$ INFO )
C .. Scalar Arguments ..
CHARACTER JP
INTEGER INFO, IWARN, L
DOUBLE PRECISION EFOR, EOUT, EPOS, LAMBDA, XIN, YIN
C .. Array Arguments ..
DOUBLE PRECISION CTETA(*), EPSBCK(*), SALPH(*), STETA(*), XF(*),
$ YQ(*)
</PRE>
<A name="Arguments"><B><FONT SIZE="+1">Arguments</FONT></B></A>
<P>
<B>Mode Parameters</B>
<PRE>
JP CHARACTER*1
Indicates whether the user wishes to apply both prediction
and filtering parts, as follows:
= 'B': Both prediction and filtering parts are to be
applied;
= 'P': Only the prediction section is to be applied.
</PRE>
<B>Input/Output Parameters</B>
<PRE>
L (input) INTEGER
The length of the impulse response of the equivalent
transversal filter model. L >= 1.
LAMBDA (input) DOUBLE PRECISION
Square root of the forgetting factor.
For tracking capabilities and exponentially stable error
propagation, LAMBDA < 1.0 (strict inequality) should
be used. 0.0 < LAMBDA <= 1.0.
XIN (input) DOUBLE PRECISION
The input sample at instant n.
(The situation just before and just after the call of
the routine are denoted by instant (n-1) and instant n,
respectively.)
YIN (input) DOUBLE PRECISION
If JP = 'B', then YIN must contain the reference sample
at instant n.
Otherwise, YIN is not referenced.
EFOR (input/output) DOUBLE PRECISION
On entry, this parameter must contain the square root of
exponentially weighted forward prediction error energy
at instant (n-1). EFOR >= 0.0.
On exit, this parameter contains the square root of the
exponentially weighted forward prediction error energy
at instant n.
XF (input/output) DOUBLE PRECISION array, dimension (L)
On entry, this array must contain the transformed forward
prediction variables at instant (n-1).
On exit, this array contains the transformed forward
prediction variables at instant n.
EPSBCK (input/output) DOUBLE PRECISION array, dimension (L+1)
On entry, the leading L elements of this array must
contain the normalized a posteriori backward prediction
error residuals of orders zero through L-1, respectively,
at instant (n-1), and EPSBCK(L+1) must contain the
square-root of the so-called "conversion factor" at
instant (n-1).
On exit, this array contains the normalized a posteriori
backward prediction error residuals, plus the square root
of the conversion factor at instant n.
CTETA (input/output) DOUBLE PRECISION array, dimension (L)
On entry, this array must contain the cosines of the
rotation angles used in time updates, at instant (n-1).
On exit, this array contains the cosines of the rotation
angles at instant n.
STETA (input/output) DOUBLE PRECISION array, dimension (L)
On entry, this array must contain the sines of the
rotation angles used in time updates, at instant (n-1).
On exit, this array contains the sines of the rotation
angles at instant n.
YQ (input/output) DOUBLE PRECISION array, dimension (L)
On entry, if JP = 'B', then this array must contain the
orthogonally transformed reference vector at instant
(n-1). These elements are also the tap multipliers of an
equivalent normalized lattice least-squares filter.
Otherwise, YQ is not referenced and can be supplied as
a dummy array (i.e., declare this array to be YQ(1) in
the calling program).
On exit, if JP = 'B', then this array contains the
orthogonally transformed reference vector at instant n.
EPOS (output) DOUBLE PRECISION
The a posteriori forward prediction error residual.
EOUT (output) DOUBLE PRECISION
If JP = 'B', then EOUT contains the a posteriori output
error residual from the least-squares filter at instant n.
SALPH (output) DOUBLE PRECISION array, dimension (L)
The element SALPH(i), i=1,...,L, contains the opposite of
the i-(th) reflection coefficient for the least-squares
normalized lattice predictor (whose value is -SALPH(i)).
</PRE>
<B>Warning Indicator</B>
<PRE>
IWARN INTEGER
= 0: no warning;
= 1: an element to be annihilated by a rotation is less
than the machine precision (see LAPACK Library
routine DLAMCH).
</PRE>
<B>Error Indicator</B>
<PRE>
INFO INTEGER
= 0: successful exit;
< 0: if INFO = -i, the i-th argument had an illegal
value.
</PRE>
<A name="Method"><B><FONT SIZE="+1">Method</FONT></B></A>
<PRE>
The output error EOUT at instant n, denoted by EOUT(n), is the
reference sample minus a linear combination of L successive input
samples:
L-1
EOUT(n) = YIN(n) - SUM h_i * XIN(n-i),
i=0
where YIN(n) and XIN(n) are the scalar samples at instant n.
A least-squares filter uses those h_0,...,h_{L-1} which minimize
an exponentially weighted sum of successive output errors squared:
n
SUM [LAMBDA**(2(n-k)) * EOUT(k)**2].
k=1
Each subroutine call performs a time update of the least-squares
filter using a fast least-squares algorithm derived from a
QR decomposition, as described in references [1] and [2] (the
notation from [2] is followed in the naming of the arrays).
The algorithm does not compute the parameters h_0,...,h_{L-1} from
the above formula, but instead furnishes the parameters of an
equivalent normalized least-squares lattice filter, which are
available from the arrays SALPH (reflection coefficients) and YQ
(tap multipliers), as well as the exponentially weighted input
signal energy
n L
SUM [LAMBDA**(2(n-k)) * XIN(k)**2] = EFOR**2 + SUM XF(i)**2.
k=1 i=1
For more details on reflection coefficients and tap multipliers,
references [2] and [4] are recommended.
</PRE>
<A name="References"><B><FONT SIZE="+1">References</FONT></B></A>
<PRE>
[1] Proudler, I. K., McWhirter, J. G., and Shepherd, T. J.
Fast QRD based algorithms for least-squares linear
prediction.
Proceedings IMA Conf. Mathematics in Signal Processing
Warwick, UK, December 1988.
[2] Regalia, P. A., and Bellanger, M. G.
On the duality between QR methods and lattice methods in
least-squares adaptive filtering.
IEEE Trans. Signal Processing, SP-39, pp. 879-891,
April 1991.
[3] Regalia, P. A.
Numerical stability properties of a QR-based fast
least-squares algorithm.
IEEE Trans. Signal Processing, SP-41, June 1993.
[4] Lev-Ari, H., Kailath, T., and Cioffi, J.
Least-squares adaptive lattice and transversal filters:
A unified geometric theory.
IEEE Trans. Information Theory, IT-30, pp. 222-236,
March 1984.
</PRE>
<A name="Numerical Aspects"><B><FONT SIZE="+1">Numerical Aspects</FONT></B></A>
<PRE>
The algorithm requires O(L) operations for each subroutine call.
It is backward consistent for all input sequences XIN, and
backward stable for persistently exciting input sequences,
assuming LAMBDA < 1.0 (see [3]).
If the condition of the signal is very poor (IWARN = 1), then the
results are not guaranteed to be reliable.
</PRE>
<A name="Comments"><B><FONT SIZE="+1">Further Comments</FONT></B></A>
<PRE>
1. For tracking capabilities and exponentially stable error
propagation, LAMBDA < 1.0 should be used. LAMBDA is typically
chosen slightly less than 1.0 so that "past" data are
exponentially forgotten.
2. Prior to the first subroutine call, the variables must be
initialized. The following initial values are recommended:
XF(i) = 0.0, i=1,...,L
EPSBCK(i) = 0.0 i=1,...,L
EPSBCK(L+1) = 1.0
CTETA(i) = 1.0 i=1,...,L
STETA(i) = 0.0 i=1,...,L
YQ(i) = 0.0 i=1,...,L
EFOR = 0.0 (exact start)
EFOR = "small positive constant" (soft start).
Soft starts are numerically more reliable, but result in a
biased least-squares solution during the first few iterations.
This bias decays exponentially fast provided LAMBDA < 1.0.
If sigma is the standard deviation of the input sequence
XIN, then initializing EFOR = sigma*1.0E-02 usually works
well.
</PRE>
<A name="Example"><B><FONT SIZE="+1">Example</FONT></B></A>
<P>
<B>Program Text</B>
<PRE>
* FD01AD EXAMPLE PROGRAM TEXT
*
* .. Parameters ..
INTEGER NIN, NOUT, NOUT1
PARAMETER ( NIN = 5, NOUT = 6, NOUT1 = 7 )
DOUBLE PRECISION ZERO, ONE
PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
INTEGER IMAX, LMAX
PARAMETER ( IMAX = 500, LMAX = 10 )
DOUBLE PRECISION LAMBDA
PARAMETER ( LAMBDA = 0.99D0 )
* .. Local Scalars ..
CHARACTER JP
INTEGER I, INFO, IWARN, L
DOUBLE PRECISION DELTA, EFOR, EOUT, EPOS, XIN, YIN
* .. Local Arrays ..
DOUBLE PRECISION CTETA(LMAX), EPSBCK(LMAX+1), SALPH(LMAX),
$ STETA(LMAX), XF(LMAX), YQ(LMAX)
* .. External Functions ..
DOUBLE PRECISION XFCN, YFCN
EXTERNAL XFCN, YFCN
* NOTE: XFCN() generates at each iteration the next sample of the
* input sequence. YFCN() generates at each iteration the next
* sample of the reference sequence. These functions are user
* defined (obtained from data acquisition devices, for
* example).
* .. External Subroutines ..
EXTERNAL FD01AD
*
* .. File for the output error sequence ..
OPEN ( UNIT = NOUT1, FILE = 'ERR.OUT', STATUS = 'REPLACE' )
* .. Executable Statements ..
*
WRITE ( NOUT, FMT = 99999 )
* Skip the heading in the data file and read the data.
READ ( NIN, FMT = '()' )
READ ( NIN, FMT = * ) L, DELTA, JP
IF ( L.LE.0 .OR. L.GT.LMAX ) THEN
WRITE ( NOUT, FMT = 99992 ) L
ELSE
IF ( DELTA.LT.ZERO ) THEN
WRITE ( NOUT, FMT = 99991 )
ELSE
*
DO 10 I = 1, L
CTETA(I) = ONE
STETA(I) = ZERO
EPSBCK(I) = ZERO
XF(I) = ZERO
YQ(I) = ZERO
10 CONTINUE
EPSBCK(L+1) = ONE
EFOR = DELTA
* .. Run least squares filter.
DO 20 I = 1, IMAX
XIN = XFCN(I)
YIN = YFCN(I)
CALL FD01AD( JP, L, LAMBDA, XIN, YIN, EFOR, XF, EPSBCK,
$ CTETA, STETA, YQ, EPOS, EOUT, SALPH, IWARN,
$ INFO)
WRITE(NOUT1,*) EOUT
20 CONTINUE
CLOSE(NOUT1)
* NOTE: File 'ERR.OUT' now contains the output error
* sequence.
*
IF ( INFO.NE.0 ) THEN
WRITE ( NOUT, FMT = 99998 ) INFO
ELSE
WRITE ( NOUT, FMT = 99997 )
DO 30 I = 1, L
WRITE ( NOUT, FMT = 99996 ) I, XF(I), YQ(I), EPSBCK(I)
30 CONTINUE
WRITE ( NOUT, FMT = 99995 ) L+1, EPSBCK(L+1)
WRITE ( NOUT, FMT = 99994 ) EFOR
IF ( IWARN.NE.0 ) THEN
WRITE ( NOUT, FMT = 99993 ) IWARN
END IF
END IF
END IF
END IF
STOP
*
99999 FORMAT (' FD01AD EXAMPLE PROGRAM RESULTS', /1X)
99998 FORMAT (' INFO on exit from FD01AD = ', I2)
99997 FORMAT (' i', 7X, 'XF(i)', 7X, 'YQ(i)', 6X, 'EPSBCK(i)', /1X)
99996 FORMAT ( I3, 2X, 3(2X, F10.6))
99995 FORMAT ( I3, 28X, F10.6, /1X)
99994 FORMAT (' EFOR = ', D10.3)
99993 FORMAT (' IWARN on exit from FD01AD = ', I2)
99992 FORMAT (/' L is out of range.',/' L = ',I5)
99991 FORMAT (/' The exponentially weighted forward prediction error',
$ ' energy must be non-negative.' )
*
END
*
* .. Example functions ..
*
DOUBLE PRECISION FUNCTION XFCN( I )
* .. Intrinsic Functions ..
INTRINSIC DBLE, SIN
* .. Local Scalar ..
INTEGER I
* .. Executable Statements ..
XFCN = SIN( 0.3D0*DBLE( I ) )
* *** Last line of XFCN ***
END
*
DOUBLE PRECISION FUNCTION YFCN( I )
* .. Intrinsic Functions ..
INTRINSIC DBLE, SIN
* .. Local Scalar ..
INTEGER I
* .. Executable Statements ..
YFCN = 0.5D0 * SIN( 0.3D0*DBLE( I ) ) +
$ 2.0D0 * SIN( 0.3D0*DBLE( I-1 ) )
* *** Last line of YFCN ***
END
</PRE>
<B>Program Data</B>
<PRE>
FD01AD EXAMPLE PROGRAM DATA
2 1.0D-2 B
</PRE>
<B>Program Results</B>
<PRE>
FD01AD EXAMPLE PROGRAM RESULTS
i XF(i) YQ(i) EPSBCK(i)
1 4.880088 12.307615 -0.140367
2 -1.456881 2.914057 -0.140367
3 0.980099
EFOR = 0.197D-02
</PRE>
<HR>
<p>
<A HREF=..\libindex.html><B>Return to index</B></A></BODY>
</HTML>
|