source: distools/issym.m @ 131

Last change on this file since 131 was 10, checked in by bduin, 14 years ago
File size: 865 bytes
RevLine 
[10]1%ISSYM Check whether a Matrix is Symmetric
2%
3%   OK = ISSYM(A,DELTA)
4%
5% INPUT
6%   A      Dataset
7%   DELTA  Parameter for the precision check (optional; default: 1e-13)
8%
9% OUTPUT
10%   OK     1 if the matrix A is symmetric and error otherwise.
11%
12% DESCRIPTION
13% A is considered as a symmetric matrix, when it is square and
14% max(max(A-A')) is smaller than DELTA.
15%
16
17% Copyright: Elzbieta Pekalska, ela.pekalska@googlemail.com
18% Faculty EWI, Delft University of Technology and
19% School of Computer Science, University of Manchester
20
21
22function [ok,nn] = issym(A,delta)
23
24if nargin < 2,
25  prwarning(6,'The precision is not provided, set up to 1e-13.');
26  delta = 1e-13;
27end
28
29A = +A;
30[m,k] = size(A);
31if m ~= k,
32  error ('Matrix should be square.')
33end
34nn = max(max((A-A')));
35ok = (nn < delta);
36
37if ~ok & nargout == 0
38  error('Symmetric matrix expected.')
39end
40       
41return;
Note: See TracBrowser for help on using the repository browser.