Home > manopt > manifolds > ttfixedrank > TTeMPS_1.1 > algorithms > linearsystem > solvePrecond_noSaddle.m

solvePrecond_noSaddle

PURPOSE ^

TTeMPS Toolbox.

SYNOPSIS ^

function xi = solvePrecond_noSaddle(L, P, rhs, xL, xR, opts, G )

DESCRIPTION ^

   TTeMPS Toolbox. 
   Michael Steinlechner, 2013-2016
   Questions and contact: michael.steinlechner@epfl.ch
   BSD 2-clause license, see LICENSE.txt

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %   TTeMPS Toolbox.
0002 %   Michael Steinlechner, 2013-2016
0003 %   Questions and contact: michael.steinlechner@epfl.ch
0004 %   BSD 2-clause license, see LICENSE.txt
0005 
0006 function xi = solvePrecond_noSaddle(L, P, rhs, xL, xR, opts, G  )
0007 % L is the operator that represents the (inexact) Euclidean Hessian
0008 %    needs a apply(L, X) interface but can be anything
0009 % P is the preconditioner for Lh; should be a TTeMPS_op_laplace operator
0010 
0011 if isa(L,'parameterdependent')
0012     if opts.tediousPrec
0013         n = xL.size;
0014         P_Ls = repmat( {sparse(n(2),n(2))}, 1, xR.order );
0015         P_Ls{1} = L.A{1};
0016         [P_rhs, B1, B3] = precond_laplace_overlapJacobi( P_Ls, rhs, xL, xR, G );
0017     else
0018         P_rhs = precond_rankOne( L, rhs, xL, xR );
0019     end
0020 else
0021     % TODO make these not all the same?
0022     P_Ls = repmat( {P.L0}, 1, xR.order );
0023     % we start with the preconditioned residual, so that is one step of the
0024     % pcg solver if we would have started with zero initial guess
0025     [P_rhs, B1, B3] = precond_laplace_overlapJacobi( P_Ls, rhs, xL, xR, G );                
0026 end
0027 
0028             
0029 function y = fun_A(x)        
0030     % x is a vectorized tangent
0031     x_tangent = fill_with_vectorized( dummy, x );        
0032     x_ttemps = tangent_to_TTeMPS( x_tangent );
0033     x_ttemps = apply(L, x_ttemps);
0034     y_tangent = TTeMPS_tangent_orth( xL, xR, x_ttemps );
0035     y = vectorize_tangent( y_tangent );
0036 end
0037 
0038 function y = fun_P(x)        
0039     x_tangent = fill_with_vectorized( dummy, x );        
0040     if isa(L,'parameterdependent') && ~opts.tediousPrec
0041         eta = precond_rankOne( L, x_tangent, xL, xR );
0042     else
0043        eta = precond_laplace_overlapJacobi( P_Ls, x_tangent, xL, xR, G, B1, B3 ); 
0044     end
0045     y = vectorize_tangent( eta );
0046 end
0047 
0048 if opts.precond_maxit > 1
0049     dummy = rhs;
0050         
0051     tol = opts.precond_tol;
0052     maxit = opts.precond_maxit-1;  % minus one !!
0053 
0054     [xi_vec,flag,relres,iter] = pcg(@fun_A, vectorize_tangent(rhs), tol, maxit, @fun_P, [], vectorize_tangent(P_rhs) );
0055     disp(['pcg converged after ' num2str(iter) 'iterations']);
0056     xi = fill_with_vectorized( dummy, xi_vec );
0057 else
0058     xi = P_rhs;
0059 end
0060 
0061 end

Generated on Fri 30-Sep-2022 13:18:25 by m2html © 2005