0001 function [c]=times(a,b)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if (nargin == 2 )
0017
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