Home > tt2 > core > tt_mkron.m

tt_mkron

PURPOSE ^

Compute Kronecker product of many TT-tensors.

SYNOPSIS ^

function [res]=tt_mkron(tt_arr)

DESCRIPTION ^

Compute Kronecker product of many TT-tensors. 
   [RES]=TT_MKRON(TT_ARR) Computes Kronecker product of many TT tensors
   TT_ARR is a cell array of TT tensors, and the result RES is the 
   Kronecker product of them. It is much faster, then taking them
   one-by-one. Works in TT1.0 format (still).


 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 [res]=tt_mkron(tt_arr)
0002 %Compute Kronecker product of many TT-tensors.
0003 %   [RES]=TT_MKRON(TT_ARR) Computes Kronecker product of many TT tensors
0004 %   TT_ARR is a cell array of TT tensors, and the result RES is the
0005 %   Kronecker product of them. It is much faster, then taking them
0006 %   one-by-one. Works in TT1.0 format (still).
0007 %
0008 %
0009 % TT-Toolbox 2.2, 2009-2012
0010 %
0011 %This is TT Toolbox, written by Ivan Oseledets et al.
0012 %Institute of Numerical Mathematics, Moscow, Russia
0013 %webpage: http://spring.inm.ras.ru/osel
0014 %
0015 %For all questions, bugs and suggestions please mail
0016 %ivan.oseledets@gmail.com
0017 %---------------------------
0018 if ( size(tt_arr,1) == 1 ) 
0019   tt_arr=tt_arr';
0020 end
0021 N=size(tt_arr,1);
0022 dsz=zeros(N,1);
0023 for k=1:N
0024     if ( iscell(tt_arr{k}) ) 
0025       dsz(k) = size(tt_arr{k},1);
0026     else
0027       dsz(k) = 1;     
0028     end
0029 end
0030 d=sum(dsz(1:N));
0031 res=cell(d,1);
0032 pos=1;
0033 for k=1:N
0034   for i=1:dsz(k)
0035       if ( ~iscell(tt_arr{k}))
0036         res{pos}=tt_arr{k};
0037       else
0038      res{pos}=tt_arr{k}{i};
0039       end
0040      pos=pos+1;
0041   end
0042 end
0043 pos=dsz(1)+1;
0044 for k=2:N
0045     fx=res{pos};
0046     ncur=size(fx,1); r=size(fx,2);
0047     res{pos}=reshape(fx,[ncur,1,r]);
0048     pos = pos + dsz(k);
0049 end
0050 
0051 return
0052 end

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