0001
0002 switch update_mode
0003 case 'init0'
0004 switch delx_mode
0005 case 'mil'
0006 iAtA = pinv(A(:,gamma_xh)'*A(:,gamma_xh));
0007 delx = iAtA*rhs(gamma_xh);
0008 case {'qr','chol'}
0009 [Q R] = qr(A(:,gamma_xh),0);
0010 delx = R\(R'\rhs(gamma_xh));
0011 case 'qrM'
0012 [Q0 R0] = qr(A(:,gamma_xh));
0013 delx = R0\(R0'\rhs(gamma_xh));
0014 end
0015 case 'init1'
0016 switch delx_mode
0017 case 'mil'
0018
0019 iAtA = opts.iAtA;
0020 delx = iAtA*rhs(gamma_xh);
0021
0022
0023 case 'qr'
0024 Q = opts.Q;
0025 R = opts.R;
0026 delx = R\(R'\rhs(gamma_xh));
0027
0028 case 'qrM'
0029 Q0 = opts.Q0;
0030 R0 = opts.R0;
0031 delx = R0\(R0'\rhs(gamma_xh));
0032
0033 case 'chol'
0034 R = opts.R;
0035 delx = R\(R'\rhs(gamma_xh));
0036 end
0037
0038 case 'update'
0039
0040 in_delx.rhs = rhs;
0041 in_delx.itr = iter;
0042 in_delx.M = M;
0043 switch delx_mode
0044 case 'mil'
0045 in_delx.iAtA = iAtA;
0046 in_delx.delx = delx;
0047 in_delx.type = delx_mode;
0048 out = compute_delx(in_delx,A);
0049 delx = out.delx;
0050 iAtA = out.iAtA;
0051 case 'qr'
0052 in_delx.R = R;
0053 in_delx.Q = Q;
0054 in_delx.delx = delx;
0055 in_delx.type = delx_mode;
0056 in_delx.nre = 2;
0057 out = compute_delx(in_delx,A);
0058 R = out.R;
0059 Q = out.Q;
0060 delx = out.delx;
0061 case 'qrM'
0062 in_delx.R0 = R0;
0063 in_delx.Q0 = Q0;
0064 in_delx.delx = gamma_xh;
0065 in_delx.type = 'qrM';
0066 out = compute_delx(in_delx,A);
0067 R0 = out.R0;
0068 Q0 = out.Q0;
0069 delx = out.delx;
0070 case 'chol'
0071 in_delx.R = R;
0072 in_delx.delx = delx;
0073 in_delx.type = delx_mode;
0074 out = compute_delx(in_delx,A);
0075 R = out.R;
0076 delx = out.delx;
0077 case 'cg'
0078
0079
0080 in_delx.x0 = xk_1;
0081 in_delx.Gamma = gamma_xh;
0082 in_delx.delx = [];
0083 in_delx.W = in.W_new(gamma_xh);
0084 in_delx.type = 'cg';
0085 delta = theta;
0086 in_delx.rhs = cg_rhs-(epsilon+delta)*d-(1-epsilon-delta)*ds+tau*sign(pk_old);
0087 out = compute_delx(in_delx,A);
0088 delx = (out.delx-xk_1(gamma_xh))/delta;
0089 stp = 1;
0090 end
0091 case 'recompute'
0092 switch delx_mode
0093 case 'mil'
0094 delx = iAtA*rhs(gamma_xh);
0095
0096
0097 case {'qr','chol'}
0098 delx = R\(R'\rhs(gamma_xh));
0099 case 'qrM'
0100 delx = R0\(R0'\rhs(gamma_xh));
0101 end
0102 end