Home > tt2 > tests > test_cross.m

test_cross

PURPOSE ^

Simple function to test the cross method

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

Simple function to test the cross method

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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 mv=@(x) sqrt(x)+abs(x);
0010 %elem_fun=@(x) 1.0./(dot((x-1),p)+1e-3); %Just sum of everything
0011 %elem_fun=@(x) mv(1e-12+dot(x-1,p)*h);
0012 
0013 %Compare functions of TT-tensors
0014 x=tt_x(d,2); x=tt_tensor(x); 
0015 e=tt_ones(d,2);e=tt_tensor(e);
0016 x=a*e+h*x; x=round(x,1e-13);
0017 x1=kron(e,x); x2=kron(x,e);
0018 rs=x1.^2+x2.^2; rs=round(rs,1e-13);
0019 %fun=@(x) 1.0./sqrt(x);
0020 %fun=@(x) 1.0./x;
0021 fun=@(x) exp(-x.^4);
0022 %fun = @(x) x.^2;
0023 rs=x;
0024 %elem_fun = @(ind) fun(rs(ind));
0025 %elem_fun=@(ind) rs(ind);
0026 %elem_fun=@(x) sqrt(x(1))+x(2);
0027 elem_fun = @(ind) fun(rs(ind));
0028 eps=1e-6;
0029 D=ndims(rs);
0030 %y=tt_rc2(2*d,2,elem_fun,1e-12);
0031 y=tt_rc(D,2,elem_fun,1e-6,'nswp',40);
0032 %v=tt_rand(size(y),ndims(y),2);
0033 %y=y+v; y=round(y,1e-12);
0034 %y1=tt_rc(D,2,elem_fun,1e-8,'nswp',40,'x0',y);
0035 
0036 z=funcrs2(rs,fun,1e-6,rs,20);
0037 z=round(z,1e-12);
0038 z1=tt_rc(D,2,elem_fun,1e-8,'nswp',40,'x0',z);
0039 
0040

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