]> gitweb.michael.orlitzky.com - octave.git/blobdiff - spectral_radius.m
Add the spectral_radius() function.
[octave.git] / spectral_radius.m
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