Home > tt2 > @tt_tensor > dot2.m

dot2

PURPOSE ^

Computes the scalar product of tt1 and tt2 as a product of numbers

SYNOPSIS ^

function [nrm]=dot2(tt1,tt2)

DESCRIPTION ^

Computes the scalar product of tt1 and tt2 as a product of numbers
   [rm]=DOT2(TT1,TT2) --- rm is a vector of length d


 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]=dot2(tt1,tt2)
0002 %Computes the scalar product of tt1 and tt2 as a product of numbers
0003 %   [rm]=DOT2(TT1,TT2) --- rm is a vector of length d
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=tt1.d;
0017 n=tt1.n;
0018 r1=tt1.r;
0019 r2=tt2.r;
0020 ps1=tt1.ps;
0021 ps2=tt2.ps;
0022 core1=tt1.core;
0023 core2=tt2.core;
0024 
0025 nrm=zeros(d,1); %The norm array
0026 p=1; %Vector p is r1(i)xr2(i)
0027 for i=1:d
0028    cr1=core1(ps1(i):ps1(i+1)-1);
0029    cr1=reshape(cr1,[r1(i),n(i)*r1(i+1)]);
0030    p=p'*cr1; %p is now r2(i)*n(i)*r1(i+1), sum over r2(i)*n(i);
0031   p=reshape(p,[r2(i)*n(i),r1(i+1)]);
0032    cr2=core2(ps2(i):ps2(i+1)-1);
0033    cr2=reshape(cr2,[r2(i)*n(i),r2(i+1)]);
0034    p=p'*cr2;
0035    nrm(i)=norm(p,'fro');
0036    p=p./nrm(i);
0037 end

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