4 Revision 1.15 2004/06/26 03:50:14 markster
5 Merge source cleanups (bug #1911)
7 Revision 1.14 2003/02/12 13:59:15 matteo
8 mer feb 12 14:56:57 CET 2003
10 Revision 1.1.1.1 2003/02/12 13:59:15 matteo
11 mer feb 12 14:56:57 CET 2003
13 Revision 1.2 2000/01/05 08:20:39 markster
14 Some OSS fixes and a few lpc changes to make it actually work
16 * Revision 1.1 1996/08/19 22:32:00 jaf
22 /* -- translated by f2c (version 19951025).
23 You must link the resulting object file with the libraries:
24 -lf2c -lm (in that order)
29 #ifdef P_R_O_T_O_T_Y_P_E_S
30 extern int invert_(integer
*order
, real
*phi
, real
*psi
, real
*rc
);
33 /* **************************************************************** */
35 /* INVERT Version 45G */
38 * Revision 1.15 2004/06/26 03:50:14 markster
39 * Merge source cleanups (bug #1911)
41 * Revision 1.14 2003/02/12 13:59:15 matteo
42 * mer feb 12 14:56:57 CET 2003
44 * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
45 * mer feb 12 14:56:57 CET 2003
47 * Revision 1.2 2000/01/05 08:20:39 markster
48 * Some OSS fixes and a few lpc changes to make it actually work
50 * Revision 1.1 1996/08/19 22:32:00 jaf
53 /* Revision 1.3 1996/03/18 20:52:47 jaf */
54 /* Just added a few comments about which array indices of the arguments */
55 /* are used, and mentioning that this subroutine has no local state. */
57 /* Revision 1.2 1996/03/13 16:51:32 jaf */
58 /* Comments added explaining that none of the local variables of this */
59 /* subroutine need to be saved from one invocation to the next. */
61 /* Eliminated a comment from the original, describing a local array X */
62 /* that appeared nowhere in the code. */
64 /* Revision 1.1 1996/02/07 14:47:20 jaf */
65 /* Initial revision */
68 /* **************************************************************** */
70 /* Invert a covariance matrix using Choleski decomposition method. */
73 /* ORDER - Analysis order */
74 /* PHI(ORDER,ORDER) - Covariance matrix */
75 /* Indices (I,J) read, where ORDER .GE. I .GE. J .GE. 1.*/
76 /* All other indices untouched. */
77 /* PSI(ORDER) - Column vector to be predicted */
78 /* Indices 1 through ORDER read. */
80 /* RC(ORDER) - Pseudo reflection coefficients */
81 /* Indices 1 through ORDER written, and then possibly read.
84 /* V(ORDER,ORDER) - Temporary matrix */
85 /* Same indices written as read from PHI. */
86 /* Many indices may be read and written again after */
87 /* initially being copied from PHI, but all indices */
88 /* are written before being read. */
90 /* NOTE: Temporary matrix V is not needed and may be replaced */
91 /* by PHI if the original PHI values do not need to be preserved. */
93 /* Subroutine */ int invert_(integer
*order
, real
*phi
, real
*psi
, real
*rc
)
95 /* System generated locals */
96 integer phi_dim1
, phi_offset
, i__1
, i__2
, i__3
;
102 real v
[100] /* was [10][10] */;
106 * Revision 1.15 2004/06/26 03:50:14 markster
107 * Merge source cleanups (bug #1911)
109 * Revision 1.14 2003/02/12 13:59:15 matteo
110 * mer feb 12 14:56:57 CET 2003
112 * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
113 * mer feb 12 14:56:57 CET 2003
115 * Revision 1.2 2000/01/05 08:20:39 markster
116 * Some OSS fixes and a few lpc changes to make it actually work
118 * Revision 1.1 1996/08/19 22:32:00 jaf
121 /* Revision 1.3 1996/03/29 22:03:47 jaf */
122 /* Removed definitions for any constants that were no longer used. */
124 /* Revision 1.2 1996/03/26 19:34:33 jaf */
125 /* Added comments indicating which constants are not needed in an */
126 /* application that uses the LPC-10 coder. */
128 /* Revision 1.1 1996/02/07 14:43:51 jaf */
129 /* Initial revision */
131 /* LPC Configuration parameters: */
132 /* Frame size, Prediction order, Pitch period */
133 /* Parameters/constants */
134 /* Local variables that need not be saved */
135 /* Decompose PHI into V * D * V' where V is a triangular matrix whose */
136 /* main diagonal elements are all 1, V' is the transpose of V, and */
137 /* D is a vector. Here D(n) is stored in location V(n,n). */
138 /* Parameter adjustments */
142 phi_offset
= phi_dim1
+ 1;
147 for (j
= 1; j
<= i__1
; ++j
) {
149 for (i__
= j
; i__
<= i__2
; ++i__
) {
150 v
[i__
+ j
* 10 - 11] = phi
[i__
+ j
* phi_dim1
];
153 for (k
= 1; k
<= i__2
; ++k
) {
154 save
= v
[j
+ k
* 10 - 11] * v
[k
+ k
* 10 - 11];
156 for (i__
= j
; i__
<= i__3
; ++i__
) {
157 v
[i__
+ j
* 10 - 11] -= v
[i__
+ k
* 10 - 11] * save
;
160 /* Compute intermediate results, which are similar to RC's */
161 if ((r__1
= v
[j
+ j
* 10 - 11], abs(r__1
)) < 1e-10f
) {
166 for (k
= 1; k
<= i__2
; ++k
) {
167 rc
[j
] -= rc
[k
] * v
[j
+ k
* 10 - 11];
169 v
[j
+ j
* 10 - 11] = 1.f
/ v
[j
+ j
* 10 - 11];
170 rc
[j
] *= v
[j
+ j
* 10 - 11];
174 r__1
= min(r__2
,.999f
);
175 rc
[j
] = max(r__1
,-.999f
);
178 /* Zero out higher order RC's if algorithm terminated early */
181 for (i__
= j
; i__
<= i__1
; ++i__
) {
184 /* Back substitute for PC's (if needed) */
185 /* 110 DO J = ORDER,1,-1 */
188 /* PC(J) = PC(J) - PC(I)*V(J,I) */