mload.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. $Log$
  3. Revision 1.15 2004/06/26 03:50:14 markster
  4. Merge source cleanups (bug #1911)
  5. Revision 1.14 2003/02/12 13:59:15 matteo
  6. mer feb 12 14:56:57 CET 2003
  7. Revision 1.1.1.1 2003/02/12 13:59:15 matteo
  8. mer feb 12 14:56:57 CET 2003
  9. Revision 1.2 2000/01/05 08:20:39 markster
  10. Some OSS fixes and a few lpc changes to make it actually work
  11. * Revision 1.1 1996/08/19 22:31:25 jaf
  12. * Initial revision
  13. *
  14. */
  15. /* -- translated by f2c (version 19951025).
  16. You must link the resulting object file with the libraries:
  17. -lf2c -lm (in that order)
  18. */
  19. #include "f2c.h"
  20. #ifdef P_R_O_T_O_T_Y_P_E_S
  21. extern int mload_(integer *order, integer *awins, integer *awinf, real *speech, real *phi, real *psi);
  22. #endif
  23. /* ***************************************************************** */
  24. /* MLOAD Version 48 */
  25. /* $Log$
  26. * Revision 1.15 2004/06/26 03:50:14 markster
  27. * Merge source cleanups (bug #1911)
  28. *
  29. * Revision 1.14 2003/02/12 13:59:15 matteo
  30. * mer feb 12 14:56:57 CET 2003
  31. *
  32. * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
  33. * mer feb 12 14:56:57 CET 2003
  34. *
  35. * Revision 1.2 2000/01/05 08:20:39 markster
  36. * Some OSS fixes and a few lpc changes to make it actually work
  37. *
  38. * Revision 1.1 1996/08/19 22:31:25 jaf
  39. * Initial revision
  40. * */
  41. /* Revision 1.5 1996/03/27 23:59:51 jaf */
  42. /* Added some more accurate comments about which indices of the argument */
  43. /* array SPEECH are read. I thought that this might be the cause of a */
  44. /* problem I've been having, but it isn't. */
  45. /* Revision 1.4 1996/03/26 19:16:53 jaf */
  46. /* Commented out the code at the end that copied the lower triangular */
  47. /* half of PHI into the upper triangular half (making the resulting */
  48. /* matrix symmetric). The upper triangular half was never used by later */
  49. /* code in subroutine ANALYS. */
  50. /* Revision 1.3 1996/03/18 21:16:00 jaf */
  51. /* Just added a few comments about which array indices of the arguments */
  52. /* are used, and mentioning that this subroutine has no local state. */
  53. /* Revision 1.2 1996/03/13 16:47:41 jaf */
  54. /* Comments added explaining that none of the local variables of this */
  55. /* subroutine need to be saved from one invocation to the next. */
  56. /* Revision 1.1 1996/02/07 14:48:01 jaf */
  57. /* Initial revision */
  58. /* ***************************************************************** */
  59. /* Load a covariance matrix. */
  60. /* Input: */
  61. /* ORDER - Analysis order */
  62. /* AWINS - Analysis window start */
  63. /* AWINF - Analysis window finish */
  64. /* SPEECH(AWINF) - Speech buffer */
  65. /* Indices MIN(AWINS, AWINF-(ORDER-1)) through */
  66. /* MAX(AWINF, AWINS+(ORDER-1)) read. */
  67. /* As long as (AWINF-AWINS) .GE. (ORDER-1), */
  68. /* this is just indices AWINS through AWINF. */
  69. /* Output: */
  70. /* PHI(ORDER,ORDER) - Covariance matrix */
  71. /* Lower triangular half and diagonal written, and read.*/
  72. /* Upper triangular half untouched. */
  73. /* PSI(ORDER) - Prediction vector */
  74. /* Indices 1 through ORDER written, */
  75. /* and most are read after that. */
  76. /* This subroutine has no local state. */
  77. /* Subroutine */ int mload_(integer *order, integer *awins, integer *awinf,
  78. real *speech, real *phi, real *psi)
  79. {
  80. /* System generated locals */
  81. integer phi_dim1, phi_offset, i__1, i__2;
  82. /* Local variables */
  83. integer c__, i__, r__, start;
  84. /* Arguments */
  85. /* Local variables that need not be saved */
  86. /* Load first column of triangular covariance matrix PHI */
  87. /* Parameter adjustments */
  88. --psi;
  89. phi_dim1 = *order;
  90. phi_offset = phi_dim1 + 1;
  91. phi -= phi_offset;
  92. --speech;
  93. /* Function Body */
  94. start = *awins + *order;
  95. i__1 = *order;
  96. for (r__ = 1; r__ <= i__1; ++r__) {
  97. phi[r__ + phi_dim1] = 0.f;
  98. i__2 = *awinf;
  99. for (i__ = start; i__ <= i__2; ++i__) {
  100. phi[r__ + phi_dim1] += speech[i__ - 1] * speech[i__ - r__];
  101. }
  102. }
  103. /* Load last element of vector PSI */
  104. psi[*order] = 0.f;
  105. i__1 = *awinf;
  106. for (i__ = start; i__ <= i__1; ++i__) {
  107. psi[*order] += speech[i__] * speech[i__ - *order];
  108. }
  109. /* End correct to get additional columns of PHI */
  110. i__1 = *order;
  111. for (r__ = 2; r__ <= i__1; ++r__) {
  112. i__2 = r__;
  113. for (c__ = 2; c__ <= i__2; ++c__) {
  114. phi[r__ + c__ * phi_dim1] = phi[r__ - 1 + (c__ - 1) * phi_dim1] -
  115. speech[*awinf + 1 - r__] * speech[*awinf + 1 - c__] +
  116. speech[start - r__] * speech[start - c__];
  117. }
  118. }
  119. /* End correct to get additional elements of PSI */
  120. i__1 = *order - 1;
  121. for (c__ = 1; c__ <= i__1; ++c__) {
  122. psi[c__] = phi[c__ + 1 + phi_dim1] - speech[start - 1] * speech[start
  123. - 1 - c__] + speech[*awinf] * speech[*awinf - c__];
  124. }
  125. /* Copy lower triangular section into upper (why bother?) */
  126. /* I'm commenting this out, since the upper triangular half of PHI
  127. */
  128. /* is never used by later code, unless a sufficiently high level of
  129. */
  130. /* tracing is turned on. */
  131. /* DO R = 1,ORDER */
  132. /* DO C = 1,R-1 */
  133. /* PHI(C,R) = PHI(R,C) */
  134. /* END DO */
  135. /* END DO */
  136. return 0;
  137. } /* mload_ */