Line | |
---|
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 | |
---|
22 | function [ok,nn] = issym(A,delta) |
---|
23 | |
---|
24 | if nargin < 2, |
---|
25 | prwarning(6,'The precision is not provided, set up to 1e-13.'); |
---|
26 | delta = 1e-13; |
---|
27 | end |
---|
28 | |
---|
29 | A = +A; |
---|
30 | [m,k] = size(A); |
---|
31 | if m ~= k, |
---|
32 | error ('Matrix should be square.') |
---|
33 | end |
---|
34 | nn = max(max((A-A'))); |
---|
35 | ok = (nn < delta); |
---|
36 | |
---|
37 | if ~ok & nargout == 0 |
---|
38 | error('Symmetric matrix expected.') |
---|
39 | end |
---|
40 | |
---|
41 | return; |
---|
Note: See
TracBrowser
for help on using the repository browser.