-
Notifications
You must be signed in to change notification settings - Fork 0
/
dd_check.m
48 lines (43 loc) · 859 Bytes
/
dd_check.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function [dflag, discrC, discrR] = dd_check(A)
% Author: N. SOULTANIS , AM: 1054319, Date: 8/1/2020
[rows, cols] = size(A);
dflag = 1;
discrR = Inf;
discrC = Inf;
for i = 1:rows
sum = 0;
for j = 1:cols
if j == i % skip diag
continue;
else
sum = sum + abs(A(i, j));
end
end
temp = abs(A(i, i)) - sum;
if temp < discrR
discrR = temp;
end
end
for i = 1:cols
sum = 0;
for j = 1:rows
if j == i % skip diag
continue;
else
sum = sum + abs(A(j, i));
end
end
temp = abs(A(i, i)) - sum;
if temp < discrC
discrC = temp;
end
end
% returning correct values
if discrR < 0
dflag = 0;
discrR = 0;
end
if discrC < 0
dflag = 0;
discrC = 0;
end