home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / octave-1.1.1p1-bin.lha / lib / octave / 1.1.1 / m / control / is_controllable.m < prev    next >
Text File  |  1996-10-12  |  2KB  |  74 lines

  1. # Copyright (C) 1993, 1994, 1995 John W. Eaton
  2. # This file is part of Octave.
  3. # Octave is free software; you can redistribute it and/or modify it
  4. # under the terms of the GNU General Public License as published by the
  5. # Free Software Foundation; either version 2, or (at your option) any
  6. # later version.
  7. # Octave is distributed in the hope that it will be useful, but WITHOUT
  8. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  10. # for more details.
  11. # You should have received a copy of the GNU General Public License
  12. # along with Octave; see the file COPYING.  If not, write to the Free
  13. # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  14.  
  15. function retval = is_controllable (a, b, tol)
  16.  
  17. # Usage: is_controllable (a, b {,tol})
  18. #
  19. # Returns 1 if the pair (a, b) is controllable, or 0 if not.
  20. #
  21. # See also: size, rows, columns, length, is_matrix, is_scalar, is_vector
  22. #
  23. # This should really use the method below, but I'm being lazy for now:
  24. #
  25. # Controllability is determined by applying Arnoldi iteration with
  26. # complete re-orthogonalization to obtain an orthogonal basis of the
  27. # Krylov subspace.
  28. #
  29. # (FIX ME... The Krylov subspace approach is not done yet!)
  30. #                      n-1
  31. #   span ([b,a*b,...,a^   b]).
  32. #
  33. # tol is a roundoff paramter, set to 2*eps if omitted.
  34.  
  35. # Written by A. S. Hodel (scotte@eng.auburn.edu) August, 1993.
  36.  
  37.   if (nargin == 2 || nargin == 3)
  38.  
  39.     n = is_square (a);
  40.     [nr, nc] = size (b);
  41.  
  42.     if (n == 0 || n != nr || nc == 0)
  43.       retval = 0;
  44.     else
  45.  
  46.       m = b;
  47.       tmp = b;
  48.       for ii = 1:(n-1)
  49.         tmp = a * tmp;
  50.         m = [m, tmp];
  51.       endfor
  52.  
  53. # If n is of any significant size, m will be low rank, so be careful!
  54.  
  55.       if (nargin == 3)
  56.         if (is_scalar (tol))
  57.           retval = (rank (m, tol) == n);
  58.         else
  59.           error ("is_controllable: tol must be a scalar");
  60.         endif
  61.       else
  62.         retval = (rank (m) == n);
  63.       endif
  64.     endif
  65.   else
  66.     usage ("is_controllable (a, b)");
  67.   endif
  68.  
  69. endfunction
  70.