Home > manopt > manifolds > ttfixedrank > TTeMPS_1.1 > @TTeMPS_op_laplace > TTeMPS_op_laplace.m

TTeMPS_op_laplace

PURPOSE ^

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 classdef TTeMPS_op_laplace
0002 % TTeMPS_op_laplace
0003 %
0004 %   A MATLAB class for representing and manipulating
0005 %   Laplace-like operators in the TT/MPS operator format,
0006 %
0007 %   Laplace-like operators are of the form
0008 %         L \otimes I \otimes I \otimes I
0009 %       + I \otimes L \otimes I \otimes I
0010 %       + ...
0011 %       + I \otimes I \otimes I \otimes L
0012 %
0013 %   with e.g. L being the discrete 1D-Laplacian matrix.
0014 
0015 %   TTeMPS Toolbox.
0016 %   Michael Steinlechner, 2013-2016
0017 %   Questions and contact: michael.steinlechner@epfl.ch
0018 %   BSD 2-clause license, see LICENSE.txt
0019 
0020 properties( SetAccess = public, GetAccess = public )
0021 
0022     L0
0023     U           % core tensors as 4D doubles
0024     rank
0025     order
0026     size_row
0027     size_col
0028     V_L
0029     E_L
0030 
0031 end
0032 
0033 % Set methods for Cores
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];  % the TT rank is always two for such Laplace-like tensors
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     %LAPLACE Construct a tensor in TT/MPS format and return TTeMPS_op_laplace object.
0060     %
0061     %   A = TTEMPS_OP_LAPLACE( L, D ) creates the D-dimensional Laplace-like
0062     %       TT/MPS operator using the supplied matrix L.
0063     %
0064     %
0065         if nargin == 1
0066             % debug constructor
0067             A.U = varargin{1};
0068             A = update_properties( A );
0069             A.L0 = [];
0070             A.V_L = [];
0071             A.E_L = [];
0072         % Default constructor
0073         elseif (nargin == 2)
0074 
0075             % only one matrix passed
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     % Other public functions
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

Generated on Fri 30-Sep-2022 13:18:25 by m2html © 2005