0001
0002
0003
0004
0005
0006 rng(11);
0007
0008 disp('Number of dimensions:')
0009 d = 5
0010
0011 disp('Define tensor size:')
0012 n = [7 8 9 10 11]
0013
0014 disp('Define rank vector (note that in the TT/MPS format, both the first and last rank are 1):')
0015 r = [1 4 5 6 7 1]
0016
0017 disp('Create two random TT/MPS tensors:')
0018 X = TTeMPS_rand( r, n )
0019 Y = TTeMPS_rand( r, n )
0020
0021 disp('Calculate inner product between them:')
0022 ip = innerprod( X, Y )
0023
0024 disp('Left-orthogonalize X:')
0025 X = orthogonalize( X, 1 )
0026
0027 disp('Right-orthogonalize Y:')
0028 Y = orthogonalize( Y, Y.order )
0029
0030 disp('Add X and Y')
0031 Z = X + Y
0032
0033 disp('Truncate Z back to rank r:')
0034 Z_trunc = truncate(Z, r)
0035
0036 disp('Note that we also have the round() operations,')
0037 disp('where you specify a desired accuracy instead of prescribed rank')
0038 Z_round = round(Z, 1e-2)