3 * Revision 1.1 1996/08/19 22:32:00 jaf
9 /* -- translated by f2c (version 19951025).
10 You must link the resulting object file with the libraries:
11 -lf2c -lm (in that order)
16 extern int invert_(integer
*order
, real
*phi
, real
*psi
, real
*rc
);
18 /* **************************************************************** */
20 /* INVERT Version 45G */
23 * Revision 1.1 1996/08/19 22:32:00 jaf
26 /* Revision 1.3 1996/03/18 20:52:47 jaf */
27 /* Just added a few comments about which array indices of the arguments */
28 /* are used, and mentioning that this subroutine has no local state. */
30 /* Revision 1.2 1996/03/13 16:51:32 jaf */
31 /* Comments added explaining that none of the local variables of this */
32 /* subroutine need to be saved from one invocation to the next. */
34 /* Eliminated a comment from the original, describing a local array X */
35 /* that appeared nowhere in the code. */
37 /* Revision 1.1 1996/02/07 14:47:20 jaf */
38 /* Initial revision */
41 /* **************************************************************** */
43 /* Invert a covariance matrix using Choleski decomposition method. */
46 /* ORDER - Analysis order */
47 /* PHI(ORDER,ORDER) - Covariance matrix */
48 /* Indices (I,J) read, where ORDER .GE. I .GE. J .GE. 1.*/
49 /* All other indices untouched. */
50 /* PSI(ORDER) - Column vector to be predicted */
51 /* Indices 1 through ORDER read. */
53 /* RC(ORDER) - Pseudo reflection coefficients */
54 /* Indices 1 through ORDER written, and then possibly read.
57 /* V(ORDER,ORDER) - Temporary matrix */
58 /* Same indices written as read from PHI. */
59 /* Many indices may be read and written again after */
60 /* initially being copied from PHI, but all indices */
61 /* are written before being read. */
63 /* NOTE: Temporary matrix V is not needed and may be replaced */
64 /* by PHI if the original PHI values do not need to be preserved. */
66 /* Subroutine */ int invert_(integer
*order
, real
*phi
, real
*psi
, real
*rc
)
68 /* System generated locals */
69 integer phi_dim1
, phi_offset
, i__1
, i__2
, i__3
;
75 real v
[100] /* was [10][10] */;
79 /* LPC Configuration parameters: */
80 /* Frame size, Prediction order, Pitch period */
81 /* Parameters/constants */
82 /* Local variables that need not be saved */
83 /* Decompose PHI into V * D * V' where V is a triangular matrix whose */
84 /* main diagonal elements are all 1, V' is the transpose of V, and */
85 /* D is a vector. Here D(n) is stored in location V(n,n). */
86 /* Parameter adjustments */
90 phi_offset
= phi_dim1
+ 1;
95 for (j
= 1; j
<= i__1
; ++j
) {
97 for (i__
= j
; i__
<= i__2
; ++i__
) {
98 v
[i__
+ j
* 10 - 11] = phi
[i__
+ j
* phi_dim1
];
101 for (k
= 1; k
<= i__2
; ++k
) {
102 save
= v
[j
+ k
* 10 - 11] * v
[k
+ k
* 10 - 11];
104 for (i__
= j
; i__
<= i__3
; ++i__
) {
105 v
[i__
+ j
* 10 - 11] -= v
[i__
+ k
* 10 - 11] * save
;
108 /* Compute intermediate results, which are similar to RC's */
109 if ((r__1
= v
[j
+ j
* 10 - 11], abs(r__1
)) < 1e-10f
) {
114 for (k
= 1; k
<= i__2
; ++k
) {
115 rc
[j
] -= rc
[k
] * v
[j
+ k
* 10 - 11];
117 v
[j
+ j
* 10 - 11] = 1.f
/ v
[j
+ j
* 10 - 11];
118 rc
[j
] *= v
[j
+ j
* 10 - 11];
122 r__1
= min(r__2
,.999f
);
123 rc
[j
] = max(r__1
,-.999f
);
126 /* Zero out higher order RC's if algorithm terminated early */
129 for (i__
= j
; i__
<= i__1
; ++i__
) {
132 /* Back substitute for PC's (if needed) */
133 /* 110 DO J = ORDER,1,-1 */
136 /* PC(J) = PC(J) - PC(I)*V(J,I) */