t3_sum_stack#

t3toolbox.backend.t3_linalg.t3_sum_stack(x, axis=None)#
def t3_sum_stack(
        x:      typ.Tuple[typ.Sequence[NDArray], typ.Sequence[NDArray]],  # (tucker_cores, tt_cores)
        axis:   typ.Union[int, typ.Sequence[int], None] = None,  # stack axes to sum over (None: all)
) -> typ.Tuple[
    typ.Tuple[NDArray, ...],  # summed_tucker_cores
    typ.Tuple[NDArray, ...],  # summed_tt_cores
]:

Sum the dense tensors represented by a stacked Tucker tensor train over stack axes.

This is the genuine tensor sum (summing the represented dense tensors), NOT a corewise sum of the core arrays. The summed-over stack axes are removed; any remaining stack axes are kept.

Ranks grow: summing over stack axes whose sizes multiply to S multiplies every Tucker and TT rank by S. This is the S-fold generalization of t3_add (which is the S=2 case): the stack is folded into the Tucker ranks (by merging) and into the TT ranks (block-diagonally), then the leading and trailing TT tails are squashed, which performs the sum.

Parameters:
  • x (t3toolbox.backend.common.typ.Tuple[t3toolbox.backend.common.typ.Sequence[NDArray], t3toolbox.backend.common.typ.Sequence[NDArray]])

  • axis (t3toolbox.backend.common.typ.Union[int, t3toolbox.backend.common.typ.Sequence[int], None])

Return type:

t3toolbox.backend.common.typ.Tuple[t3toolbox.backend.common.typ.Tuple[NDArray, Ellipsis], t3toolbox.backend.common.typ.Tuple[NDArray, Ellipsis]]