Returns A*X+P*Y in the TT-format. [RES]=TT_AXPY(A,X,P,Y,EPS,MAX_RANK) Returns a*X+p*Y in TT format. Compress each summand with respect to its norm. Compress the result to accuracy EPS and (optional) maximal rank MAX_RANK TT-Toolbox 2.2, 2009-2012 This is TT Toolbox, written by Ivan Oseledets et al. Institute of Numerical Mathematics, Moscow, Russia webpage: http://spring.inm.ras.ru/osel For all questions, bugs and suggestions please mail ivan.oseledets@gmail.com --------------------------- d = size(x, 1);
0001 function [res]=tt_axpy(a, x, p, y, eps, max_rank) 0002 %Returns A*X+P*Y in the TT-format. 0003 % [RES]=TT_AXPY(A,X,P,Y,EPS,MAX_RANK) Returns a*X+p*Y in TT format. 0004 % Compress each summand with respect to its norm. Compress the result to 0005 % accuracy EPS and (optional) maximal rank MAX_RANK 0006 % 0007 % 0008 % TT-Toolbox 2.2, 2009-2012 0009 % 0010 %This is TT Toolbox, written by Ivan Oseledets et al. 0011 %Institute of Numerical Mathematics, Moscow, Russia 0012 %webpage: http://spring.inm.ras.ru/osel 0013 % 0014 %For all questions, bugs and suggestions please mail 0015 %ivan.oseledets@gmail.com 0016 %--------------------------- 0017 % d = size(x, 1); 0018 if ((nargin<6)||(isempty(max_rank))) 0019 max_rank=[]; 0020 end; 0021 0022 % nrmx = tt_dot(x,x); 0023 % nrmy = tt_dot(y,y); 0024 % eps1 = (abs(a)*nrmx+abs(p)*nrmy)/(abs(a)*nrmx); 0025 % eps2 = (abs(a)*nrmx+abs(p)*nrmy)/(abs(p)*nrmy); 0026 % 0027 % % aa = abs(a) 0028 % % ap = abs(p) 0029 % 0030 % if (eps1>2) 0031 % % eps1 0032 % x = tt_compr2(x, min(eps*eps1, 0.5), max_rank); 0033 % end; 0034 % if (eps2>2) 0035 % % eps2 0036 % y = tt_compr2(y, min(eps*eps2, 0.5), max_rank); 0037 % end; 0038 0039 ax = tt_scal(x, a); 0040 py = tt_scal(y, p); 0041 0042 res = tt_add(ax,py); 0043 res = tt_compr2(res, eps, max_rank); 0044 0045 % res = tt_stabilize(res,0); 0046 0047 end