0001
0002
0003
0004
0005
0006 function [eta] = precond_rankOne( A, xi, xL, xR )
0007
0008
0009 r = xL.rank;
0010 n = xL.size;
0011 d = xL.order;
0012
0013
0014 eta = xi;
0015 xi = tangent_to_TTeMPS( xi );
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 Y = cell(1,d);
0026
0027 left = innerprod( xL, xi, 'LR', d-1, true );
0028 right = innerprod( xR, xi, 'RL', 2, true );
0029
0030
0031 Y{1} = tensorprod_ttemps( xi.U{1}, right{2}, 3 );
0032
0033 for idx = 2:d-1
0034 res = tensorprod_ttemps( xi.U{idx}, left{idx-1}, 1 );
0035 Y{idx} = tensorprod_ttemps( res, right{idx+1}, 3 );
0036 end
0037
0038 Y{d} = tensorprod_ttemps( xi.U{d}, left{d-1}, 1 );
0039
0040
0041 tmp = (19.4*A.A{1}) \ unfold( Y{1}, 'left' );
0042 eta.dU{1} = reshape( tmp, [r(1), n(1), r(2)]);
0043
0044 x1 = matricize( xL.U{1}, 2);
0045 y = xL;
0046 y.U{1} = tensorize( (19.4*A.A{1})*x1, 2, [r(1), n(1), r(2)] );
0047 B1 = innerprod( xL, y, 'LR', d-1, true);
0048 for i=2:d
0049 tmp = B1{i-1} \ unfold(Y{i}, 'right');
0050 eta.dU{i} = reshape( tmp, [r(i), n(i), r(i+1)] );
0051 end
0052
0053 eta = TTeMPS_tangent_orth( xL, xR, eta );
0054
0055 end
0056