Home > tt2 > @qtt_tucker > times.m

times

PURPOSE ^

C=A.*B

SYNOPSIS ^

function [c]=times(a,b)

DESCRIPTION ^

C=A.*B
   [C]=TIMES(A,B) Hadamard product of two QTT-tuckers


 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 [c]=times(a,b)
0002 %C=A.*B
0003 %   [C]=TIMES(A,B) Hadamard product of two QTT-tuckers
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 if (nargin == 2 )
0017     % times of tucker factors (whatever it is)
0018     d = a.dphys;
0019     c = qtt_tucker;
0020     c.dphys = d;
0021     c.tuck = cell(d,1);
0022     for i=1:d
0023         c.tuck{i} = a.tuck{i}.*b.tuck{i};
0024     end;
0025     c.core = tt_tensor;
0026     c.core.d = d;
0027     rca = a.core.r;
0028     rcb = b.core.r;
0029     rta = a.core.n;
0030     rtb = b.core.n;
0031     c.core.r = rca.*rcb;
0032     c.core.n = rta.*rtb;
0033     c.core.ps = cumsum([1; c.core.r(1:d).*c.core.n.*c.core.r(2:d+1)]);
0034     c.core.core = zeros(c.core.ps(d+1)-1,1);
0035     for i=1:d
0036         cra = a.core{i};
0037         cra = reshape(cra, rca(i)*rta(i)*rca(i+1), 1);
0038         crb = b.core{i};
0039         crb = reshape(crb, 1, rcb(i)*rtb(i)*rcb(i+1));
0040         crc = cra*crb;
0041         crc = reshape(crc, rca(i), rta(i), rca(i+1), rcb(i), rtb(i), rcb(i+1));
0042         crc = permute(crc, [1, 4, 2, 5, 3, 6]);
0043         c.core.core(c.core.ps(i):c.core.ps(i+1)-1) = crc(:);
0044     end;
0045 end
0046 return
0047 end

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