0001 classdef TTeMPS_op
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 properties( SetAccess = private, GetAccess = public )
0015
0016 U
0017 rank
0018 order
0019 size_row
0020 size_col
0021
0022 end
0023
0024
0025 methods
0026
0027 function A = set.U( A, U_);
0028
0029 A.U = U_;
0030 A = update_properties( A );
0031
0032 end
0033
0034
0035 function A = update_properties( A );
0036
0037 rank_ = cellfun( @(x) size(x,1), A.U);
0038 A.rank = [rank_, size(A.U{end},4)];
0039 A.size_col = cellfun( @(y) size(y,2), A.U);
0040 A.size_row = cellfun( @(y) size(y,3), A.U);
0041 A.order = length( A.size_row );
0042
0043 end
0044
0045 end
0046
0047
0048
0049 methods( Access = public )
0050
0051 function A = TTeMPS_op(varargin)
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 if (nargin == 0)
0066
0067 A = TTeMPS_op( {0 0 0} );
0068 return;
0069
0070 elseif (nargin == 1)
0071
0072
0073 A.U = varargin{1};
0074
0075 A = update_properties( A );
0076
0077 else
0078 error('Invalid number of arguments.')
0079 end
0080 end
0081
0082
0083 disp( A, name );
0084 display( A );
0085
0086 res = contract( A, x, y, idx );
0087 B = TTeMPS_op_to_TT_matrix( A );
0088 B = TTeMPS_op_to_TTeMPS( A );
0089 y = apply( A, x, idx );
0090 A = round(A, tol );
0091
0092 A = plus( A, B );
0093 A = mtimes( B, A );
0094
0095 Afull = full( A );
0096
0097 end
0098
0099 end