home *** CD-ROM | disk | FTP | other *** search
/ Shareware 1 2 the Maxx / sw_1.zip / sw_1 / PROGRAM / MATRIX04.ZIP / MATTOEPZ.C < prev    next >
C/C++ Source or Header  |  1992-05-22  |  1KB  |  44 lines

  1. /*
  2. *-----------------------------------------------------------------------------
  3. *    file:    mattoepz.c
  4. *    desc:    matrix mathematics - toeplitz matrix
  5. *    by:    ko shu pui, patrick
  6. *    date:    26 nov 91 v0.1
  7. *    revi:    14 may 92 v0.2
  8. *    ref:
  9. *       [1] Mary L.Boas, "Mathematical Methods in the Physical Sciene,"
  10. *    John Wiley & Sons, 2nd Ed., 1983. Chap 3.
  11. *
  12. *-----------------------------------------------------------------------------
  13. */
  14.  
  15. #include <stdio.h>
  16.  
  17. #include "matrix.h"
  18.  
  19. /*
  20. *-----------------------------------------------------------------------------
  21. *    funct:    mat_SymToeplz
  22. *    desct:    create a n x n symmetric Toeplitz matrix from
  23. *        a n x 1 correlation matrix
  24. *    given:    R = correlation matrix (n x 1)
  25. *    retrn:    the symmetric Toeplitz matrix
  26. *-----------------------------------------------------------------------------
  27. */
  28. MATRIX mat_SymToeplz( R )
  29. MATRIX R;
  30. {
  31.     int    i, j, n;
  32.     MATRIX    T;
  33.  
  34.     n = MatRow(R);
  35.     T = mat_creat(n, n, UNDEFINED);
  36.  
  37.     for (i=0; i<n; i++)
  38.     for (j=0; j<n; j++)
  39.         {
  40.         T[i][j] = R[abs(i-j)][0];
  41.         }
  42.     return (T);
  43. }
  44.