Mercurial > repos > public > sbplib
changeset 1217:a3d9567d9004 feature/d2_compatible
Improve efficiency of construction of D2(b) by precomputing as much as possible
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Wed, 13 Nov 2019 14:54:22 -0800 |
parents | 2924b3a9b921 |
children | 50102334c85b |
files | +sbp/D2VariableCompatible.m |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
diff -r 2924b3a9b921 -r a3d9567d9004 +sbp/D2VariableCompatible.m --- a/+sbp/D2VariableCompatible.m Fri Aug 16 14:30:28 2019 -0700 +++ b/+sbp/D2VariableCompatible.m Wed Nov 13 14:54:22 2019 -0800 @@ -48,20 +48,21 @@ end obj.borrowing.H11 = obj.H(1,1)/obj.h; % First element in H/h, obj.borrowing.M.d1 = obj.H(1,1)/obj.h; % First element in H/h is borrowing also for M - obj.borrowing.R.delta_D = inf; % Because delta_D is zero, one can borrow infinitely much. - % This sets penalties of the form 1/borrowing to 0, which is - % the desired behaviour. + obj.borrowing.R.delta_D = inf; obj.m = m; obj.M = []; + D1 = obj.D1; e_r = obj.e_r; e_l = obj.e_l; % D2 = Hinv * (-M + br*er*d1r^T - bl*el*d1l^T); % Replace d1' by e'*D1 in D2. - D2_compatible = @(b) D2(b) - obj.HI*(b(m)*e_r*d1_r' - b(m)*e_r*e_r'*D1) ... - + obj.HI*(b(1)*e_l*d1_l' - b(1)*e_l*e_l'*D1); + correction_l = obj.HI*(e_l*d1_l' - e_l*e_l'*D1); + correction_r = - obj.HI*(e_r*d1_r' - e_r*e_r'*D1); + + D2_compatible = @(b) D2(b) + b(1)*correction_l + b(m)*correction_r; obj.D2 = D2_compatible; obj.d1_l = (e_l'*D1)'; @@ -73,6 +74,7 @@ end end + end