[SOLVED] CS function [dx,dy,ds] = newtonsolve(NS,r,p,q)

$25

File Name: CS_function_[dx,dy,ds]_=_newtonsolve(NS,r,p,q).zip
File Size: 433.32 KB

5/5 - (1 vote)

function [dx,dy,ds] = newtonsolve(NS,r,p,q)
%NEWTONSOLVESolve linear system with factorized matrix.
%
%[dx,dy,ds] = newtonsolve(NS,r,p,q)

m = size(r,1);
n = size(p,1);

% ********************************************************************
% Solve KKT system with LU factors.
% ********************************************************************

if (NS.method == 1)
rhs = [p-q./NS.x; r];
warn_stat = warning;
warning(off,all);
lhs = NS.U(NS.Lrhs(NS.pp));
warning(warn_stat);
lhs(NS.qq) = lhs;
dx = lhs(1:n);
dy = lhs(n+1:n+m);
ds = (q-NS.s.*dx)./NS.x;
end

% ********************************************************************
% Solve KKT system with LDL factors.
% ********************************************************************

if (NS.method == 2)
rhs = [p-q./NS.x; r];
warn_stat = warning;
warning(off,all);
lhs = NS.L(NS.D(NS.Lrhs(NS.pp)));
warning(warn_stat);
lhs(NS.pp) = lhs;
dx = lhs(1:n);
dy = lhs(n+1:n+m);
ds = (q-NS.s.*dx)./NS.x;
end
end

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS function [dx,dy,ds] = newtonsolve(NS,r,p,q)
$25