test_lin_solve.m

来自「Solve linear system and test it.」· M 代码 · 共 16 行

M
16
字号
function x=test_lin_solve(y)
    s=0;n=0;
    while(1)
    A=randn(y);
    x=randn(y,1);
    n=n+1;
    if (norm(A*(lin_solve(A,x))-x)<norm(A*(A\x)-x)) s=s+1;    
    % compares accuracy of lin_solve to matlabs \
    end;
    s/n
    % s/n measures the percentage that lin_solve is more accurate than \
    % for y < 50, s/n < 0.5
    % for y > 50, s/n > 0.5
    % particularly, s/n -> 1 for y>=100
    % however lin_solve is much slower than \ for large y.
end;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?