如题:

function X = IsStrictDiagMatrix(A)
% input: A matrix
% output: The matrix after transformation % if the matrix is not a square matrix, return error
if size(A, 1) ~= size(A, 2)
error('It is not a square matrix');
end % get the size of A and set the size of X
% use an array to accord if all the row be set
N = size(A, 1);
X = zeros(N, N);
has_set = zeros(N); for i = 1 : N
% find out the max element in a row
row_max = max(abs(A(i, : )));
% if the max element is not larger than sum of others, return error
if (row_max <= (sum(abs(A(i, : ))) - row_max))
error('It can not be transformed to strict diagonal dominance matrix');
end
% find out the index of max element and set the row j of matrix X
% accord row j has been set
for j = 1 : N
if (abs(A(i, j)) == row_max)
X(j, : ) = A(i, : );
has_set(j) = 1;
end
end
end % if any hasn't been set, return error
for i = 1 : N
if (has_set == 0)
error('It can not be transformed to strict diagonal dominance matrix');
end
end % output success
fprintf('It can be transformed to a strict diagonal dominance matrix: \n');
end

最新文章

  1. zTree Jquery eCharts
  2. iOS7上的地图定位接口BUG
  3. JQuery 控制元素显示隐藏
  4. PBR实现
  5. 【iCore3 双核心板】例程十八:USB_VCP实验——虚拟串口
  6. Google protocol buffer在windows下的编译
  7. 通过pinyin4j将汉字转换为全拼 和 拼音首字母
  8. 剑指Offer:二进制中1的个数
  9. 信息安全实验二:return-to-libc
  10. Recursive Depth first search graph(adj matrix)
  11. MQTT——控制报文格式
  12. HDU - 3533 bfs [kuangbin带你飞]专题二
  13. Hexo博客搭建
  14. JAVA之列表
  15. 关于spring的源码的理解
  16. nginx简单介绍
  17. windows 下的命令操作
  18. 求1+2+……+n的和
  19. weex+vue2.x 踩坑实录(不定期更新)
  20. js+jquery检测用户浏览器型号(转)

热门文章

  1. [转]c# xml.Load() locking file on disk causing errors
  2. 51nod-1686 第K大区间(二分+尺取法)
  3. rfc 标准文档目录
  4. OGNL 对象视图导航语言
  5. SkinSoft中.vssf样式文件在VS2005中的应用(图文)
  6. C# 前台线程和后台线程
  7. MVC基础知识-持续更新....
  8. 配置Rip的认证
  9. 集合框架学习之Collection和Map详解
  10. ThinkPHP框架概述