0001 function [c]=vertcat(a,b)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 if (isempty(b) )
0020 c=a;
0021 return
0022 elseif (isempty(a) )
0023 c=b;
0024 return
0025 end
0026 c=tt_tensor;
0027 d=a.d;
0028 ra=a.r;
0029 n=a.n;
0030 psa=a.ps;
0031 cra=a.core;
0032 rb=b.r;
0033 crb=b.core;
0034 psb=b.ps;
0035 rc=ra+rb;
0036 if ( ra(d+1) == rb(d+1) )
0037 rc(d+1)=ra(d+1);
0038 else
0039 error('Incorrect sizes in [A;B], please check');
0040 end
0041 psc=cumsum([1;n.*rc(1:d).*rc(2:d+1)]);
0042 crc=zeros(1,psc(d+1)-1);
0043
0044
0045
0046
0047
0048 for i=1:d
0049 cr1=cra(psa(i):psa(i+1)-1);
0050 cr2=crb(psb(i):psb(i+1)-1);
0051 cr1=reshape(cr1,[ra(i),n(i),ra(i+1)]);
0052 cr2=reshape(cr2,[rb(i),n(i),rb(i+1)]);
0053 cr3=zeros(rc(i),n(i),rc(i+1));
0054 cr3(1:ra(i),:,1:ra(i+1))=cr1;
0055 cr3(rc(i)-rb(i)+1:rc(i),:,rc(i+1)-rb(i+1)+1:rc(i+1))=cr2;
0056 crc(psc(i):psc(i+1)-1)=cr3(:);
0057 end
0058 c.ps=psc;
0059 c.d=d;
0060 c.n=n;
0061 c.r=rc;
0062 c.core=crc;