changeset 59:2d10ab3ee69d

[project @ 1993-08-13 20:09:16 by jwe] Initial revision
author jwe
date Fri, 13 Aug 1993 20:09:16 +0000
parents e96cf7e43750
children 671f8bf989d8
files scripts/general/is_symmetric.m
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/scripts/general/is_symmetric.m
@@ -0,0 +1,23 @@
+function retval = is_symmetric (x,tol)
+
+# usage: is_symmetric (x{,tol})
+#
+# If x is symmetric, return the dimension of x, otherwise, return 0.
+#
+# See also: size, rows, columns, length, is_matrix, is_scalar, 
+# is_square, is_vector
+
+  if (nargin == 1 || nargin == 2)
+    if ((retval = is_square (x)))
+      if (nargin == 1)
+	tol = eps;
+      endif
+      if (norm (x - x') / norm(x) > tol)
+        retval = 0;
+      endif
+    endif
+  else
+    error ("usage: is_symmetric (x {,tol})");
+  endif
+
+endfunction