T3Tangent.apply#
- t3toolbox.manifold.T3Tangent.apply(ww)#
def apply( self, ww: typ.Sequence[NDArray], # apply vectors, len=d, elm_shape=W+(Ni,) ) -> NDArray: # apply(v, ww), one scalar per stack element; shape=W+K+C
Apply this tangent vector in all modes: contract the dense tangent with
wweverywhere.The all-modes special case of
probe()(probing leaves one index free; this contracts them all). It is the tangent analogue ofTuckerTensorTrain.apply(), and is cheaper than probing – a single left-to-right sweep, no right/central sweeps, no per-mode assembly. The result is stackedW + K + C(apply-vector stackWouter, tangent stackK, frame stackCinner); a plain scalar when there are no stacks.See Section 6.2.2 (Algorithms 6-7) of Alger et al. (2026), “Tucker Tensor Train Taylor Series” (arXiv:2603.21141).
Examples
>>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> import t3toolbox.frame_variations_format as bvf >>> import t3toolbox.manifold as t3m >>> x = t3.TuckerTensorTrain.randn((10, 11, 12), (5, 6, 4), (1, 2, 3, 1)) >>> frame, variations = bvf.t3_orthogonal_representations(x) >>> v = t3m.T3Tangent(frame, variations) >>> ww = (np.random.randn(10), np.random.randn(11), np.random.randn(12)) >>> a = v.apply(ww) >>> a_dense = np.einsum('ijk,i,j,k->', v.to_dense(), *ww) # dense reference >>> print(bool(abs(float(a) - float(a_dense)) < 1e-9)) True