Generates finite-difference 1D matrix of \nabla(tt_a \nabla) in QTTM format. [M] = TT_FD_MTX1(TT_A, BOUND1, BOUND2) Generates finite-difference 1D matrix of \nabla(tt_a \nabla) in QTTM format, TT_A is given in the QTT format, bound1,2 specify boundary conditions as x=0 and x=1, respectively: 0 - Dirichlet, 1 - Neumann EPS is the QTT compression tolerance TT-Toolbox 2.2, 2009-2012 This is TT Toolbox, written by Ivan Oseledets et al. Institute of Numerical Mathematics, Moscow, Russia webpage: http://spring.inm.ras.ru/osel For all questions, bugs and suggestions please mail ivan.oseledets@gmail.com ---------------------------
0001 function [M] = tt_Fd_mtx1(tt_a, bound1, bound2, eps) 0002 %Generates finite-difference 1D matrix of \nabla(tt_a \nabla) in QTTM format. 0003 % [M] = TT_FD_MTX1(TT_A, BOUND1, BOUND2) Generates finite-difference 0004 % 1D matrix of \nabla(tt_a \nabla) in QTTM format, TT_A is given in the 0005 % QTT format, bound1,2 specify boundary conditions as x=0 and x=1, 0006 % respectively: 0007 % 0 - Dirichlet, 0008 % 1 - Neumann 0009 % EPS is the QTT compression tolerance 0010 % 0011 % 0012 % TT-Toolbox 2.2, 2009-2012 0013 % 0014 %This is TT Toolbox, written by Ivan Oseledets et al. 0015 %Institute of Numerical Mathematics, Moscow, Russia 0016 %webpage: http://spring.inm.ras.ru/osel 0017 % 0018 %For all questions, bugs and suggestions please mail 0019 %ivan.oseledets@gmail.com 0020 %--------------------------- 0021 d = size(tt_a, 1); 0022 M=core(diag(tt_tensor(a))); 0023 tt_shf_a = tt_mv(tt_shf(d), tt_a); 0024 tt_last_elem_a = tt_a; 0025 for i=1:d 0026 tt_last_elem_a{i}(1,:,:)=0; 0027 end; 0028 M = ttm_add(M, tt_diag(tt_shf_a)); 0029 M = ttm_add(M, tt_diag(tt_last_elem_a)); 0030 M = tt_mat_compr(M, eps); 0031 M_shf = tt_shf_diag(tt_a, 0); 0032 M = ttm_add(M, tt_scal(M_shf, -1)); 0033 M = ttm_add(M, tt_scal(tt_transp(M_shf), -1)); 0034 M = tt_mat_compr(M, eps); 0035 M = tt_scal(M, (2^d+1)^2); 0036 0037 end