% Tucker full precision without rank reduction
for i1=0:1;for i2=0:1;for i3=0:1;
                A(i1+1,i2+1,i3+1)=i1+2*i2+4*i3;
            end;end;end;
T=tensor(A);
% built-in ALS computation
at=tucker_als(T,[2,2,2]);
ct=tensor(at);
norm(full(at)-full(T))
% by hand with SVD
a1=tenmat(T,[1]); a2=tenmat(T,[2]);
a3=tenmat(T,[3]);
[u1,s1,v1]=svd(double(a1));[u2,s2,v2]=svd(double(a2));
[u3,s3,v3]=svd(double(a3));
S=ttensor(T,u1',u2',u3');
norm(full(ttensor(S,u1,u2,u3))-full(T))