rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
fv_two_phase_hess_fun.m
1 function [res, precond] = fv_two_phase_hess_fun(params, jac, HessTemp, arg)
2 
3  Plength = params.Slength;
4  if isempty(HessTemp)
5  HessTemp = jac(1:end-1,:)'*jac(1:end-1,:);
6  end
7  if isempty(arg)
8  res = HessTemp;
9  else
10  Pscale = jac(end,end-Plength+1:end);
11  PscaleP = Pscale(:) .* arg(end-Plength+1:end);
12  res = HessTemp * arg;
13  res(end-Plength+1:end) = res(end-Plength+1:end) + Pscale(:) .* PscaleP;
14 
15  resref = (jac'*jac) * arg;
16  if norm(res - resref) > 1e-12
17  keyboard;
18  end
19  end
20 
21  if nargout == 2
22  [precond.L, precond.U] = ilu(HessTemp, struct('type', 'crout'));
23  end
24 
25 end