Approximates a full-format s-dimensional 2^{d} x...x 2^{d}-tensor full, indexed by i^{1}_{1} ,..., i^{d}_{1} ,...,..., i^{1}_{s} ,..., i^{d}_{s}, by a QTT decomposition _tt_, k-th core of which is indexed by i^{k}_{1} ,..., i^{k}_{s}, k=1,...,d August 11, 2011 Vladimir Kazeev vladimir.kazeev@gmail.com INM RAS Moscow, Russia
0001 function [tt]=tt_qfromfull(full,s,d,eps) 0002 0003 % Approximates a full-format s-dimensional 2^{d} x...x 2^{d}-tensor 0004 % full, indexed by 0005 % i^{1}_{1} ,..., i^{d}_{1} ,...,..., i^{1}_{s} ,..., i^{d}_{s}, 0006 % by a QTT decomposition _tt_, 0007 % k-th core of which is indexed by 0008 % i^{k}_{1} ,..., i^{k}_{s}, 0009 % k=1,...,d 0010 % 0011 % August 11, 2011 0012 % Vladimir Kazeev 0013 % vladimir.kazeev@gmail.com 0014 % INM RAS 0015 % Moscow, Russia 0016 % 0017 0018 0019 full=reshape(full,2*ones(1,s*d)); 0020 0021 prm=zeros(1,s*d); 0022 for k=1:d 0023 for l=1:s 0024 prm(s*k+1-l)=k+(s-l)*d; 0025 end 0026 end 0027 0028 full=permute(full,prm); 0029 full=reshape(full,[2^s*ones(1,d),1]); 0030 0031 tt=core(tt_tensor(full,eps)); 0032 for k=1:d 0033 [n,p,q]=size(tt{k}); 0034 tt{k}=reshape(tt{k},[2*ones(1,s),p,q]); 0035 end 0036 0037 return 0038 end