fv_to_t3#

t3toolbox.frame_variations_format.fv_to_t3(index, frame, variations)#
def fv_to_t3(
        index:      typ.Tuple[
            bool,  # TT core (True) or Tucker core (False)
            int,   # number of the non-orthogonal core, 1...d-1
        ],
        frame:      T3Frame,        # stack_shape = C (frame/core stack)
        variations: T3Variations,   # stack_shape = K + C (frame stack is its inner/trailing part)
) -> t3.TuckerTensorTrain:

Convert frame-variations representation to TuckerTensorTrain.

If replacement_ind=1, replace_tt=True:

1 -- L0 --(H1)-- R2 -- R3 -- 1
     |     |     |     |
     U0    U1    U2    U3
     |     |     |     |

If replacement_ind=2, replace_tt=False:

1 -- L0 -- L1 -- D2 -- R3 -- 1
     |     |     |     |
     U0    U1   (V2)   U3
     |     |     |     |

These are the single-core variation terms summed in equation (47), Appendix A.3, of Alger et al. (2026), “Tucker Tensor Train Taylor Series” (arXiv:2603.21141).

Parameters:
  • ii (int) – Index of variation. 0 <= replacement_ind < num_cores

  • replace_tt (bool) – Indicates whether to use TT variation (True) or a Tucker variation (False)

  • frame (T3Frame) – Frame cores

  • variations (T3Variations) – Variation cores

  • index (t3toolbox.backend.common.typ.Tuple[bool, int])

Raises:

RuntimeError

  • Error raised if the frame and variations do not fit with each other

Return type:

TuckerTensorTrain

Examples

>>> import numpy as np
>>> import t3toolbox.frame_variations_format as bvf
>>> import t3toolbox.corewise as cw
>>> np.random.seed(0)
>>> randn = np.random.randn
>>> (U0, U1, U2) = (randn(10, 14), randn(11, 15), randn(12, 16))
>>> (L0, L1, L2) = (randn(1, 10, 2), randn(2, 11, 3), randn(3, 12, 4))
>>> (R0, R1, R2) = (randn(2, 10, 4), randn(4, 11, 5), randn(5, 12, 1))
>>> (D0, D1, D2) = (randn(1, 9, 4), randn(2, 8, 5), randn(3, 7, 1))
>>> frame = bvf.T3Frame((U0, U1, U2), (D0, D1, D2), (L0, L1, L2), (R0, R1, R2))
>>> (V0, V1, V2) = (randn(9, 14), randn(8, 15), randn(7, 16))
>>> (H0, H1, H2) = (randn(1, 10, 4), randn(2, 11, 5), randn(3, 12, 1))
>>> variations = bvf.T3Variations((V0, V1, V2), (H0, H1, H2))

Replacing the index-1 TT-core swaps H1 into the right-orthogonal chain L0, ?, R2; the Tucker (up) cores are unchanged:

>>> tt_term = bvf.fv_to_t3((True, 1), frame, variations)
>>> expected = ((U0, U1, U2), (L0, H1, R2))      # up cores untouched; TT chain = L0, H1, R2
>>> print(np.allclose(cw.corewise_norm(cw.corewise_sub(tt_term.data, expected)), 0.0))
True

Replacing the index-1 Tucker core swaps V1 into the up cores and the down core D1 into the chain:

>>> tucker_term = bvf.fv_to_t3((False, 1), frame, variations)
>>> expected = ((U0, V1, U2), (L0, D1, R2))
>>> print(np.allclose(cw.corewise_norm(cw.corewise_sub(tucker_term.data, expected)), 0.0))
True