home *** CD-ROM | disk | FTP | other *** search
/ APDL Eductation Resources / APDL Eductation Resources.iso / programs / electronic / rlab / TestMatrix / grcar_r < prev    next >
Encoding:
Text File  |  1994-06-14  |  1.2 KB  |  34 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. // Synopsis:    Grcar matrix - a Toeplitz matrix with 
  4. //              sensitive eigenvalues.
  5.  
  6. // Syntax:      G = grcar ( N , K )
  7.  
  8. // Description:
  9.  
  10. //      G is an N-by-N matrix with -1s on the subdiagonal, 1s on the
  11. //      diagonal, and K superdiagonals of 1s. The default is K = 3.
  12. //      The eigenvalues of this matrix form an interesting pattern in
  13. //      the complex plane (try PS(GRCAR(32))).
  14.  
  15. //      References:
  16. //       J.F. Grcar, Operator coefficient methods for linear equations,
  17. //            Report SAND89-8691, Sandia National Laboratories, Albuquerque,
  18. //            New Mexico, 1989 (Appendix 2).
  19. //       N.M. Nachtigal, L. Reichel and L.N. Trefethen, A hybrid GMRES
  20. //            algorithm for nonsymmetric linear systems, SIAM J. Matrix Anal.
  21. //            Appl., 13 (1992), pp. 796-825.
  22.  
  23. //    This file is a translation of grcar.m from version 2.0 of
  24. //    "The Test Matrix Toolbox for Matlab", described in Numerical
  25. //    Analysis Report No. 237, December 1993, by N. J. Higham.
  26.  
  27. //-------------------------------------------------------------------//
  28.  
  29. grcar = function ( n , k )
  30. {
  31.   if (!exist (k)) { k = 3; }
  32.   return tril(triu(ones(n,n)), k) - diag(ones(n-1,1), -1);
  33. };
  34.