]> gitweb.michael.orlitzky.com - octave.git/commitdiff
Add the spectral_radius() function.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 8 May 2013 06:42:47 +0000 (02:42 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 8 May 2013 06:42:47 +0000 (02:42 -0400)
spectral_radius.m [new file with mode: 0644]

diff --git a/spectral_radius.m b/spectral_radius.m
new file mode 100644 (file)
index 0000000..47cfd72
--- /dev/null
@@ -0,0 +1,17 @@
+function rho = spectral_radius(A)
+  %
+  % Compute the spectral radius of ``A``, which is not necessarily
+  % Hermitian.
+  %
+  % This is slow. Don't use it on big matrices.
+  %
+  % INPUT:
+  %
+  %   ``A`` -- The matrix whose spectral radius you want.
+  %
+  % OUTPUT:
+  %
+  %   ``rho`` -- The spectral radius of ``A``.
+  %
+  rho = max(abs(eig(A)));
+end