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

# orth_at

## PURPOSE

ORTH_AT Orthogonalize single core.

## SYNOPSIS

function [x, R] = orth_at(x, pos, dir, apply)

## DESCRIPTION

```ORTH_AT Orthogonalize single core.
X = ORTH_AT( X, POS, 'LEFT') left-orthogonalizes the core at position POS
and multiplies the corresponding R-factor with core POS+1. All other cores
are untouched. The modified tensor is returned.

X = ORTH_AT( X, POS, 'RIGHT') right-orthogonalizes the core at position POS
and multiplies the corresponding R-factor with core POS-1. All other cores
are untouched. The modified tensor is returned.

## CROSS-REFERENCE INFORMATION

This function calls:
• apply APPLY Application of TT/MPS operator to a TT/MPS tensor
• apply APPLY Application of TT/MPS Laplace-like operator to a TT/MPS tensor
• tensorprod_ttemps TENSORPROD_TTEMPS Tensor-times-Matrix product.
• unfold UNFOLD Left/right-unfold a 3D array.
• qr_unique Thin QR factorization ensuring diagonal of R is real, positive if possible.
This function is called by:

## SOURCE CODE

```0001 function [x, R] = orth_at(x, pos, dir, apply)
0002     %ORTH_AT Orthogonalize single core.
0003     %   X = ORTH_AT( X, POS, 'LEFT') left-orthogonalizes the core at position POS
0004     %   and multiplies the corresponding R-factor with core POS+1. All other cores
0005     %   are untouched. The modified tensor is returned.
0006     %
0007     %   X = ORTH_AT( X, POS, 'RIGHT') right-orthogonalizes the core at position POS
0008     %   and multiplies the corresponding R-factor with core POS-1. All other cores
0009     %   are untouched. The modified tensor is returned.
0010     %
0012
0013     %   TTeMPS Toolbox.
0014     %   Michael Steinlechner, 2013-2016
0015     %   Questions and contact: michael.steinlechner@epfl.ch
0017
0018     if ~exist('apply', 'var')
0019         apply = true;
0020     end
0021
0022     sz = size(x.U{pos});
0023
0024     if length(sz) == 2
0025         sz = [sz, 1];
0026     end
0027
0028     if strcmpi(dir, 'left')
0029         [Q, R] = qr_unique(unfold(x.U{pos}, 'left'));
0030         x.U{pos} = reshape(Q, [sz(1), sz(2), size(Q, 2)]);
0031
0032         if apply
0033             x.U{pos + 1} = tensorprod_ttemps(x.U{pos + 1}, R, 1);
0034         end
0035
0036     elseif strcmpi(dir, 'right')
0037         % mind the transpose as we want to orthonormalize rows
0038         [Q, R] = qr_unique(unfold(x.U{pos}, 'right')');
0039         x.U{pos} = reshape(Q', [size(Q, 2), sz(2), sz(3)]);
0040
0041         if apply
0042             x.U{pos - 1} = tensorprod_ttemps(x.U{pos - 1}, R, 3);
0043         end
0044
0045     else
0046         error('Unknown direction specified. Choose either LEFT or RIGHT')
0047     end
0048
0049 end```

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