def orthLRFull(coreList, mu, splitResult = True):
    '''
    Orthogonalize list of TT-cores.
    
    Parameters:
        :list: coreList
            list of TT-cores (stored as numpy arrays)
        :int: mu
            separating index for left and right orthogonalization.
            Output cores will be left-orthogonal for dimensions from 1 to \mu-1
            and right-orthogonal for dimensions from \mu+1 to d
        :boolean: splitResult = True
            Controls whether outut should be splitted into left-, non-, right-orthogonal
            parts or not.
    
    Returns:
        :list: resultU
            left-orthogonal cores with indices from 1 to \mu-1
        :np.array: W
            \mu-th core
        :list: reultV
            right-orthogonal cores with indices from \mu+1 to d
    OR
        :list: resultU + [W] + resultV
            concatenated list of cores
    '''
    d = len(coreList)
    assert (mu >= 0) and (mu <= d)
    resultU = []
    for k in xrange(mu):
        core = coreList[k].copy()
        if k > 0:
            core = np.einsum('ijk,li->ljk', core, R)
        [r1, n, r2] = core.shape
        if (k < mu-1):
            core = reshape(core, [r1*n, r2])
            Q, R = np.linalg.qr(core)
            rnew = Q.shape[1]
            core = reshape(Q, [r1, n, rnew])
            resultU = resultU + [core]
    if mu > 0:
        W = core.copy()
    resultV = []
    for k in xrange(d-1, mu, -1):
        core = coreList[k].copy()
        if (k < d-1):
            core = np.einsum('ijk,lk->ijl', core, R)
        [r1, n, r2] = core.shape
        if (k > mu+1):
            core = reshape(core, [r1, n*r2])
            Q, R = np.linalg.qr(core.T)
            rnew = Q.shape[1]
            core = reshape(Q.T, [rnew, n, r2])
        resultV = [core] + resultV
    if mu < d-1:
        if mu > 0:
            W = np.einsum('ijk,lk->ijl', W, R)
        else:
            W = np.einsum('ijk,lk->ijl', coreList[0], R)
    if splitResult:
        return resultU, W, resultV
    return resultU + [W] + resultV
def orthLRFull ( coreList , mu , splitResult = True ) : d = len ( coreList ) assert ( mu >= 0 ) and ( mu <= d ) resultU = [ ] for k in xrange ( mu ) : core = coreList [ k ] . copy ( ) if k > 0 : core = np . einsum ( 'ijk,li->ljk' , core , R ) [ r1 , n , r2 ] = core . shape if ( k < mu - 1 ) : core = reshape ( core , [ r1 * n , r2 ] ) Q , R = np . linalg . qr ( core ) rnew = Q . shape [ 1 ] core = reshape ( Q , [ r1 , n , rnew ] ) resultU = resultU + [ core ] if mu > 0 : W = core . copy ( ) resultV = [ ] for k in xrange ( d - 1 , mu , - 1 ) : core = coreList [ k ] . copy ( ) if ( k < d - 1 ) : core = np . einsum ( 'ijk,lk->ijl' , core , R ) [ r1 , n , r2 ] = core . shape if ( k > mu + 1 ) : core = reshape ( core , [ r1 , n * r2 ] ) Q , R = np . linalg . qr ( core . T ) rnew = Q . shape [ 1 ] core = reshape ( Q . T , [ rnew , n , r2 ] ) resultV = [ core ] + resultV if mu < d - 1 : if mu > 0 : W = np . einsum ( 'ijk,lk->ijl' , W , R ) else : W = np . einsum ( 'ijk,lk->ijl' , coreList [ 0 ] , R ) if splitResult : return resultU , W , resultV return resultU + [ W ] + resultV
Orthogonalize list of TT-cores.
    
    Parameters:
        :list: coreList
            list of TT-cores (stored as numpy arrays)
        :int: mu
            separating index for left and right orthogonalization.
            Output cores will be left-orthogonal for dimensions from 1 to \mu-1
            and right-orthogonal for dimensions from \mu+1 to d
        :boolean: splitResult = True
            Controls whether outut should be splitted into left-, non-, right-orthogonal
            parts or not.
    
    Returns:
        :list: resultU
            left-orthogonal cores with indices from 1 to \mu-1
        :np.array: W
            \mu-th core
        :list: reultV
            right-orthogonal cores with indices from \mu+1 to d
    OR
        :list: resultU + [W] + resultV
            concatenated list of cores