0001 classdef TTeMPS_op_laplace
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 properties( SetAccess = public, GetAccess = public )
0021
0022 L0
0023 U
0024 rank
0025 order
0026 size_row
0027 size_col
0028 V_L
0029 E_L
0030
0031 end
0032
0033
0034 methods
0035
0036 function A = set.U( A, U_);
0037
0038 A.U = U_;
0039 A = update_properties( A );
0040
0041 end
0042
0043
0044 function A = update_properties( A );
0045
0046 A.rank = [1, 2*ones(1, length(A.U)-1), 1];
0047 size_col_ = cellfun( @(y) size(y,1), A.U);
0048 A.size_col = size_col_ ./ (A.rank(1:end-1).*A.rank(2:end));
0049 A.size_row = cellfun( @(y) size(y,2), A.U);
0050 A.order = length( A.size_row );
0051
0052 end
0053
0054 end
0055
0056 methods( Access = public )
0057
0058 function A = TTeMPS_op_laplace(varargin)
0059
0060
0061
0062
0063
0064
0065 if nargin == 1
0066
0067 A.U = varargin{1};
0068 A = update_properties( A );
0069 A.L0 = [];
0070 A.V_L = [];
0071 A.E_L = [];
0072
0073 elseif (nargin == 2)
0074
0075
0076 L = varargin{1};
0077 A.L0 = L;
0078 d = varargin{2};
0079
0080 A.V_L = [];
0081 A.E_L = [];
0082
0083 [m,n] = size( L );
0084 E = speye( m, n );
0085 a_1 = sparse( 1, 1, 1, 2, 1 );
0086 a_mid = sparse( 2, 1, 1, 4, 1 );
0087 a_end = sparse( 2, 1, 1, 2, 1 );
0088 b_1 = sparse( 2, 1, 1, 2, 1 );
0089 b_mid = sparse( [1;4], [1;1], [1;1], 4, 1 );
0090 b_end = sparse( 1, 1, 1, 2, 1 );
0091
0092 A.U = cell( 1, d );
0093 A.U{1} = kron( L, a_1 ) + kron( E, b_1 );
0094 A_mid = kron( L, a_mid ) + kron( E, b_mid );
0095 for i=2:d-1
0096 A.U{i} = A_mid;
0097 end
0098 A.U{d} = kron( L, a_end ) + kron( E, b_end );
0099
0100 A = update_properties( A );
0101
0102 else
0103 error('Invalid number of arguments.')
0104 end
0105 end
0106
0107
0108
0109 y = apply( A, x, idx );
0110 A = mtimes( B, A );
0111 res = contract( A, x, y, idx );
0112
0113 disp( A, name );
0114 display( A );
0115
0116 B = TTeMPS_op_laplace_to_TTeMPS_op( A );
0117 B = TTeMPS_op_laplace_to_TT_matrix( A );
0118 expB = constr_precond_inner( A, X, mu );
0119
0120
0121 function A = initialize_precond( A )
0122 [A.V_L, A.E_L] = eig(full(A.L0));
0123 A.E_L = diag( A.E_L );
0124 end
0125 end
0126
0127
0128
0129 end