zoukankan      html  css  js  c++  java
  • matlab实现判断是否能否生成严格对角占优矩阵

    如题:

    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: 
    ');
    end
    
  • 相关阅读:
    3.15SQL
    SQL注入
    黑盒渗透测试【转自HACK学习-FoxRoot】
    【学校作业】某项目网络安全技术解决方案
    小米手环4使用半年后的测评报告
    GKCTF赛后复盘
    RCTF赛后复盘
    【课堂笔记】常见漏洞总结
    原型链污染问题的研究
    CTF之Web常见题型总结
  • 原文地址:https://www.cnblogs.com/wsine/p/4634590.html
Copyright © 2011-2022 走看看