0001 classdef TTeMPS_block
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 properties( SetAccess = public, GetAccess = public )
0014
0015 U
0016 mu
0017 p
0018 end
0019
0020
0021 properties( Dependent = true, SetAccess = private, GetAccess = public )
0022
0023 rank
0024 order
0025 size
0026
0027 end
0028
0029
0030 methods
0031
0032 function rank_ = get.rank(x)
0033 rank_ = cellfun( @(x) size(x,1), x.U);
0034 rank_ = [rank_, size(x.U{end},3)];
0035 end
0036
0037 function size_ = get.size(x)
0038 size_ = cellfun( @(y) size(y,2), x.U);
0039 end
0040
0041 function order_ = get.order(x)
0042 order_ = length( x.size );
0043 end
0044 end
0045
0046
0047 methods( Access = public )
0048
0049 function x = TTeMPS_block(varargin)
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 if (nargin == 0)
0064
0065 x = TTeMPS_block( {0 0 0}, 1 );
0066 return;
0067
0068 elseif (nargin == 2)
0069
0070
0071 U = varargin{1};
0072 mu = varargin{2};
0073 x = TTeMPS_block( U, mu, size(U{mu},4) );
0074 return;
0075
0076 elseif (nargin == 3)
0077
0078 x.U = varargin{1};
0079 x.mu = varargin{2};
0080 x.p = varargin{3};
0081
0082 else
0083 error('Invalid number of arguments.')
0084 end
0085 end
0086
0087 function res = TTeMPS_block_to_TTeMPS( x )
0088 mu = x.mu;
0089 tmp = permute( x.U{mu}, [1 2 4 3] );
0090 tmp = reshape( tmp, [x.rank(mu), x.size(mu)*x.p, x.rank(mu+1)]);
0091
0092 res = TTeMPS({x.U{1:mu-1}, tmp, x.U{mu+1:end}});
0093 end
0094
0095 function res = getVector( x, idx, condense )
0096 if ~exist( 'condense', 'var' )
0097 condense = false;
0098 end
0099 tmp = x.U{x.mu}(:,:,:,idx);
0100 res = TTeMPS({x.U{1:x.mu-1}, tmp, x.U{x.mu+1:end}});
0101 if condense
0102 res = round(res, 1e-16);
0103 end
0104 end
0105
0106
0107
0108 y = full( x );
0109 [x, r] = orth_at( x, pos, dir, apply );
0110 res = innerprod( x, y, dir, upto, storeParts );
0111 res = shift( x, nu, tol, maxrank);
0112 res = norm( x );
0113 res = contract( x, y, idx );
0114 x = round( x, tol );
0115 x = truncate( x, r );
0116 x = uminus( x );
0117 x = uplus( x );
0118 z = plus( x, y );
0119 z = minus( x, y );
0120 x = mtimes( a, x );
0121 z = hadamard( x, y, idx );
0122 [xl,xr,g] = gauge_matrices( x );
0123 disp( x, name );
0124 display( x );
0125
0126 end
0127
0128 methods( Static, Access = public )
0129
0130 function res = TTeMPS_to_TTeMPS_block( x, mu, p )
0131
0132 U = x.U;
0133 tmp = reshape( U{mu}, [x.rank(mu), x.size(mu)/p, p, x.rank(mu+1)]);
0134 tmp = permute( tmp, [1 2 4 3] );
0135 res = TTeMPS_block({U{1:mu-1}, tmp, U{mu+1:x.order}}, mu, p);
0136 end
0137
0138 end
0139
0140 end