Switch to unified view

a b/combinedDeepLearningActiveContour/minFunc/mcholinc.m
1
function [R,tau] = mcholinc(H,verbose)
2
% Computes Cholesky of H+tau*I, for suitably large tau that matrix is pd
3
4
p = size(H,1);
5
6
beta = norm(H,'fro');
7
if min(diag(H)) > 1e-12
8
    tau = 0;
9
else
10
    if verbose
11
        fprintf('Small Value on Diagonal, Adjusting Hessian\n');
12
    end
13
    tau = max(beta/2,1e-12);
14
end
15
while 1
16
    [R,posDef] = chol(H+tau*eye(p));
17
    if posDef == 0
18
        break;
19
    else
20
        if verbose
21
            fprintf('Cholesky Failed, Adjusting Hessian\n');
22
        end
23
        tau = max(2*tau,beta/2);
24
    end
25
end