开发者

Is there a function for checking whether a matrix is diagonally dominant (row dominance)

A matrix is diagonally dominant (by rows) if its value at the diagonal is in absolute sense greater then the sum of all other absolute values in that row. Same goes for columns, only the other way around.

Is there a function in matlab for chekcing this ? (I开发者_如何学Go could write a simple loop, but I'm trying to quit those).


Why loop?

You can easily form the sum of absolute values in a given row.

sum(abs(A),2)

Can you compare this to the absolute diagonal elements in each row?

abs(diag(A)) >= sum(abs(A),2)

Of course, this is not correct, since the diagonal terms should not be included in the first sum. Regardless, we can easily repair the problem.

(2*abs(diag(A))) >= sum(abs(A),2)

Finally, we need a result from this test. The above tests each row. A matrix is diagonally dominant if that test is true for ALL rows.

all((2*abs(diag(A))) >= sum(abs(A),2))


There is no function that I know of. However, you can make a simple test without loops.

%# create an array
array = magic(3);

%# take the absolute of the array
absArray = abs(array);

%# To be diagonally dominant, the row and column sums have to be less
%# than twice the diagonal
rowSum = sum(absArray,1)';%#' (formatting comment)
colSum = sum(absArray,2);
dia    = diag(absArray);

%# test
isDiagonallyDominantByRow = all(rowSum <= 2 * dia); 
isDiagonallyDominantByCol = all(colSum <= 2 * dia);
isTotallyDominant = isDiagonallyDominantByRow && isDiagonallyDominantByCol;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜