Home > tt2 > exp > tt_mmk2.m

tt_mmk2

PURPOSE ^

DMRG/Krylov matrix-by-matrix multiplication

SYNOPSIS ^

function [ttm12] = tt_mmk2(ttm1, ttm2, eps, max_r, max_swp)

DESCRIPTION ^

DMRG/Krylov matrix-by-matrix multiplication 
   [TTM12] = TT_MMK2(TTM1, TTM2, EPS, [MAX_R, MAX_SWP]) 
   Computes DMRG/Krylov matrix-by-matrix multiplication with accuracy EPS.
   It just calls the MVK2 code. Uses TT1.0, so it syntax will change in
   the next release


 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
---------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ttm12] = tt_mmk2(ttm1, ttm2, eps, max_r, max_swp)
0002 %DMRG/Krylov matrix-by-matrix multiplication
0003 %   [TTM12] = TT_MMK2(TTM1, TTM2, EPS, [MAX_R, MAX_SWP])
0004 %   Computes DMRG/Krylov matrix-by-matrix multiplication with accuracy EPS.
0005 %   It just calls the MVK2 code. Uses TT1.0, so it syntax will change in
0006 %   the next release
0007 %
0008 %
0009 % TT-Toolbox 2.2, 2009-2012
0010 %
0011 %This is TT Toolbox, written by Ivan Oseledets et al.
0012 %Institute of Numerical Mathematics, Moscow, Russia
0013 %webpage: http://spring.inm.ras.ru/osel
0014 %
0015 %For all questions, bugs and suggestions please mail
0016 %ivan.oseledets@gmail.com
0017 %---------------------------
0018 
0019 d = size(ttm1, 1);
0020 
0021 exists_max_r=1;
0022 if ((nargin<4)||(isempty(max_r)))
0023     exists_max_r=0;
0024 end;
0025 exists_max_swp=1;
0026 if ((nargin<5)||(isempty(max_swp)))
0027     exists_max_swp=0;
0028 end;
0029 
0030 ttmm1 = cell(d,1);
0031 
0032 ns1 = zeros(d,1);
0033 ns2 = zeros(d,1);
0034 
0035 for q=1:d
0036     n1 = size(ttm1{q},1);
0037     m = size(ttm1{q},2);
0038     n2 = size(ttm2{q},2);
0039     r1 = size(ttm1{q}, 3);
0040     r2 = size(ttm1{q}, 4);
0041     ns1(q)=n1;
0042     ns2(q)=n2;
0043     
0044     I = eye(n2);
0045     ttmm1{q}=reshape(ttm1{q}, n1, m*r1*r2);
0046     ttmm1{q}=kron(I,ttmm1{q});
0047     ttmm1{q}=reshape(ttmm1{q}, n1, n2, m, r1, r2, n2);
0048     ttmm1{q}=permute(ttmm1{q}, [1 2 3 6 4 5]);
0049     ttmm1{q}=reshape(ttmm1{q}, n1*n2, m*n2, r1, r2);
0050 %     ttmm1{q} = zeros(n1*n2, m*n2, size(ttm1{q}, 3), size(ttm1{q}, 4));
0051     
0052 %     ttmm1{q}(1,1,:,:)=ttm1{q}(1,1,:,:);
0053 %     ttmm1{q}(2,1,:,:)=ttm1{q}(1,2,:,:);
0054 %     ttmm1{q}(1,2,:,:)=ttm1{q}(2,1,:,:);
0055 %     ttmm1{q}(2,2,:,:)=ttm1{q}(2,2,:,:);
0056 %
0057 %     ttmm1{q}(3,3,:,:)=ttm1{q}(1,1,:,:);
0058 %     ttmm1{q}(4,3,:,:)=ttm1{q}(1,2,:,:);
0059 %     ttmm1{q}(3,4,:,:)=ttm1{q}(2,1,:,:);
0060 %     ttmm1{q}(4,4,:,:)=ttm1{q}(2,2,:,:);
0061 end;
0062 
0063 ttmm2 = tt_mat_to_vec(ttm2);
0064 
0065 if (exists_max_r)
0066     if (exists_max_swp)
0067         ttm12 = tt_mvk2(ttmm1, ttmm2, eps, max_r, max_swp);
0068     else
0069         ttm12 = tt_mvk2(ttmm1, ttmm2, eps, max_r);
0070     end;
0071 else
0072     if (exists_max_swp)
0073         ttm12 = tt_mvk2(ttmm1, ttmm2, eps, [], max_swp);
0074     else
0075         ttm12 = tt_mvk2(ttmm1, ttmm2, eps);
0076     end;
0077 end;
0078 
0079 ttm12 = tt_vec_to_mat(ttm12, ns1, ns2);
0080 
0081 end

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