[SOLVED] CS代考计算机代写 function [dx,dy,ds] = newtonsolve(NS,r,p,q)

30 $

File Name: CS代考计算机代写_function_[dx,dy,ds]_=_newtonsolve(NS,r,p,q).zip
File Size: 631.14 KB

SKU: 3051470836 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


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)
30 $