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

apply

PURPOSE ^

APPLY Application of TT/MPS Laplace-like operator to a TT/MPS tensor

SYNOPSIS ^

function y = apply( A, x, idx )

DESCRIPTION ^

APPLY Application of TT/MPS Laplace-like operator to a TT/MPS tensor
   Y = APPLY(A, X) applies the TT/MPS Laplace operator A to the TT/MPS tensor X.

   Y = APPLY(A, X, idx) is the application of A but only in mode idx.
       note that in this case, X is assumed to be a standard matlab array and
       not a TTeMPS tensor. 

   In both cases, X can come from a block-TT format, that is, with a four-dimensional core instead.

   See also CONTRACT

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function y = apply( A, x, idx )
0002     %APPLY Application of TT/MPS Laplace-like operator to a TT/MPS tensor
0003     %   Y = APPLY(A, X) applies the TT/MPS Laplace operator A to the TT/MPS tensor X.
0004     %
0005     %   Y = APPLY(A, X, idx) is the application of A but only in mode idx.
0006     %       note that in this case, X is assumed to be a standard matlab array and
0007     %       not a TTeMPS tensor.
0008     %
0009     %   In both cases, X can come from a block-TT format, that is, with a four-dimensional core instead.
0010     %
0011     %   See also CONTRACT
0012 
0013     %   TTeMPS Toolbox.
0014     %   Michael Steinlechner, 2013-2016
0015     %   Questions and contact: michael.steinlechner@epfl.ch
0016     %   BSD 2-clause license, see LICENSE.txt
0017 
0018 
0019     % first case: all cores.
0020     if ~exist( 'idx', 'var' )
0021         V = cell(1, A.order);
0022 
0023         for i = 1:A.order
0024             %check for possible block format
0025             p = size(x.U{i},4);
0026             if p ~= 1
0027                 Xi = permute( x.U{i}, [2 1 3 4]);
0028                 Xi = reshape( Xi, [A.size_row(i), x.rank(i)*x.rank(i+1)*p] );
0029                 V{i} = A.U{i}*Xi;
0030                 V{i} = reshape( V{i}, [A.rank(i), A.rank(i+1), A.size_col(i), x.rank(i), x.rank(i+1), p] );
0031                 V{i} = permute( V{i}, [1, 4, 3, 2, 5, 6]);
0032                 V{i} = reshape( V{i}, [A.rank(i)*x.rank(i), A.size_col(i), A.rank(i+1)*x.rank(i+1), p]);
0033             else
0034                 Xi = matricize( x.U{i}, 2);
0035                 V{i} = A.U{i}*Xi;
0036                 V{i} = reshape( V{i}, [A.rank(i), A.rank(i+1), A.size_col(i), x.rank(i), x.rank(i+1)] );
0037                 V{i} = permute( V{i}, [1, 4, 3, 2, 5]);
0038                 V{i} = reshape( V{i}, [A.rank(i)*x.rank(i), A.size_col(i), A.rank(i+1)*x.rank(i+1)]);
0039             end
0040         end
0041         y = TTeMPS( V );
0042     else
0043         %check for possible block format
0044         p = size(x,4);
0045         if p ~= 1
0046             Xi = permute( x, [2 1 3 4]);
0047             Xi = reshape( Xi, [A.size_row(idx), size(x, 1)*size(x, 3)*p] );
0048             V = A.U{idx}*Xi;
0049             V = reshape( V, [A.rank(idx), A.rank(idx+1), A.size_col(idx), size(x, 1), size(x, 3), p] );
0050             V = permute( V, [1, 4, 3, 2, 5, 6]);
0051             y = reshape( V, [A.rank(idx)*size(x, 1), A.size_col(idx), A.rank(idx+1)*size(x, 3), p]);
0052         else
0053             Xi = matricize( x, 2);
0054             V = A.U{idx}*Xi;
0055             V = reshape( V, [A.rank(idx), A.rank(idx+1), A.size_col(idx), size(x, 1), size(x, 3)] );
0056             V = permute( V, [1, 4, 3, 2, 5]);
0057             y = reshape( V, [A.rank(idx)*size(x,1), A.size_col(idx), A.rank(idx+1)*size(x,3)]);
0058         end
0059     end
0060 
0061 end

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