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

TTeMPS

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
0002 % TTeMPS
0003 %
0004 %   A MATLAB class for representing and manipulating tensors
0005 %   in the TT/MPS format.
0006 %
0007 
0008 %   TTeMPS Toolbox.
0009 %   Michael Steinlechner, 2013-2016
0010 %   Questions and contact: michael.steinlechner@epfl.ch
0011 %   BSD 2-clause license, see LICENSE.txt
0012 
0013 properties( SetAccess = public, GetAccess = public )
0014 
0015     U           % core tensors
0016 
0017 end
0018 
0019 % Dependent properties
0020 properties( Dependent = true, SetAccess = private, GetAccess = public )
0021 
0022     rank
0023     order
0024     size
0025 
0026 end
0027 
0028 % Get methods for dependent properties (computed on-the-fly)
0029 methods
0030 
0031     function rank_ = get.rank(x)
0032         rank_ = cellfun( @(x) size(x,1), x.U);
0033         rank_ = [rank_, size(x.U{end},3)];
0034     end
0035    
0036     function size_ = get.size(x)
0037         size_ = cellfun( @(y) size(y,2), x.U);
0038     end
0039 
0040     function order_ = get.order(x)
0041         order_ = length( x.U );
0042     end
0043 end
0044 
0045 
0046 methods( Access = public )
0047 
0048     function x = TTeMPS(varargin)
0049     %TTEMPS Construct a tensor in TT/MPS format and return TTeMPS object.
0050     %
0051     %   X = TTEMPS() creates a zero TT/MPS tensor
0052     %
0053     %   X = TTEMPS(CORES) creates a TT/MPS tensor with core tensors C taken
0054     %   from the cell array CORES
0055     %
0056 
0057         % Default constructor
0058         if (nargin == 0)
0059             x = TTeMPS( {0 0 0} );
0060             return;
0061         elseif (nargin == 1)
0062             x.U = varargin{1};
0063             return;
0064         else
0065             error('Invalid number of arguments.')
0066         end
0067     end
0068 
0069     % Other public functions
0070     y = full( x );
0071     [x, r] = orth_at( x, pos, dir, apply );
0072     x = orthogonalize( x, pos );
0073     res = innerprod( x, y, dir, upto, storeParts );
0074     res = norm( x, safe );
0075     res = contract( x, y, idx );
0076     x = truncate( x, r );
0077     x = uminus( x );
0078     x = uplus( x );
0079     z = plus( x, y );
0080     z = minus( x, y );
0081     x = mtimes( a, x );
0082     z = hadamard( x, y, idx );
0083     y = mergecores( x, idx );
0084     y = splitcore( x, idx, nL, nR, tol );
0085     z = hadamard_division( x, y, idx );
0086     z = TTeMPS_to_TT( x );
0087     z = cat( mu, x, y );
0088     [xl,xr,g] = gauge_matrices( x );
0089     disp( x, name );
0090     display( x );
0091     
0092 end
0093 
0094 methods( Static, Access = public )
0095     x = from_array( A, opts );
0096 end
0097 
0098 methods( Static, Access = private )
0099 
0100     x = subsref_mex( r, n, ind , C);
0101 
0102 end
0103 end

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