Home > tt2 > @tt_tensor > norm.m

norm

PURPOSE ^

Frobenius norm of the TT-tensor

SYNOPSIS ^

function [nrm] = norm(tt)

DESCRIPTION ^

Frobenius norm of the TT-tensor
   [NRM]=NORM(TT) Based on the QR-decomposition, has O(nu) accuracy


 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
---------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [nrm] = norm(tt)
0002 %Frobenius norm of the TT-tensor
0003 %   [NRM]=NORM(TT) Based on the QR-decomposition, has O(nu) accuracy
0004 %
0005 %
0006 % TT-Toolbox 2.2, 2009-2012
0007 %
0008 %This is TT Toolbox, written by Ivan Oseledets et al.
0009 %Institute of Numerical Mathematics, Moscow, Russia
0010 %webpage: http://spring.inm.ras.ru/osel
0011 %
0012 %For all questions, bugs and suggestions please mail
0013 %ivan.oseledets@gmail.com
0014 %---------------------------
0015 
0016 d=tt.d;
0017 n=tt.n;
0018 r=tt.r;
0019 pos=tt.ps;
0020 cr=tt.core;
0021 pos1=1;
0022 nrm=zeros(d,1);
0023 core0=cr(1:r(1)*n(1)*r(2));
0024 %Orthogonalization from left-to-tight
0025 for i=1:d-1
0026    core0=reshape(core0,[r(i)*n(i),r(i+1)]);
0027    [core0,ru]=qr(core0,0); nrm(i)=norm(ru,'fro');
0028    nrm(i)=max(nrm(i),1e-308);
0029    ru=ru./nrm(i);
0030    core1=cr(pos(i+1):pos(i+2)-1);
0031    core1=reshape(core1,[r(i+1),n(i+1)*r(i+2)]);
0032    core1=ru*core1;
0033    r(i+1)=size(core0,2);
0034    cr(pos1:pos1-1+r(i)*n(i)*r(i+1))=core0(:);
0035    cr(pos1+r(i)*n(i)*r(i+1):pos1+r(i)*n(i)*r(i+1)+r(i+1)*n(i+1)*r(i+2)-1)=core1(:);
0036    core0=core1;
0037    pos1=pos1+r(i)*n(i)*r(i+1);
0038 end
0039 pos1=pos1+r(d)*n(d)*r(d+1)-1;
0040 nrm(d)=norm(core0(:));
0041 nrm=prod(nrm);
0042 return
0043 end

Generated on Wed 08-Feb-2012 18:20:24 by m2html © 2005