Simple function to test the cross method
0001 %Simple function to test the cross method 0002 d=10; 0003 %elem_fun=@(x) sum(x); %Just sum of everything 0004 p=0:d-1; p = 2.^p; 0005 a=-5;b=5; 0006 n=2^d; 0007 h=(b-a)/(n-1); 0008 %mv=@(x) x.^3; 0009 %elem_fun=@(x) 1.0./(dot((x-1),p)+1e-3); %Just sum of everything 0010 %elem_fun=@(x) mv(1e-12+dot(x-1,p)*h); 0011 0012 %Compare functions of TT-tensors 0013 x=tt_x(d,2); x=tt_tensor(x); 0014 e=tt_ones(d,2);e=tt_tensor(e); 0015 x=a*e+h*x; x=round(x,1e-13); 0016 rs=x; 0017 %fun=@(x) 1.0./sqrt(x); 0018 %fun=@(x) 1.0./x; 0019 fun=@(x) exp(-(x).^4) + 1; 0020 elem_fun = @(ind) fun(rs(ind)); 0021 %elem_fun=@(ind) rs(ind); 0022 %elem_fun=@(x) sqrt(x(1))+x(2); 0023 0024 eps=1e-6; 0025 %y=tt_rc2(2*d,2,elem_fun,1e-12); 0026 y=tt_rc(d,2,elem_fun,1e-6,'nswp',40,'change_dir_on',false); 0027 0028 z=funcrs2(rs,fun,1e-12,rs,20); 0029 0030