t3_tucker_factors_shared#
- t3toolbox.backend.sharing.t3_tucker_factors_shared(x, sharing, rtol=1e-09)#
def t3_tucker_factors_shared( x: typ.Tuple[ typ.Sequence[NDArray], # tucker_cores. len=d, elm_shape=stack_shape+(ni, Ni) typ.Sequence[NDArray], # tt_cores. len=d, elm_shape=stack_shape+(ri, ni, r(i+1)) ], sharing: typ.Sequence, # len=d, static; one hashable group label per mode rtol: float = 1e-9, # relative tolerance on the factor deviation ) -> NDArray: # bool array, shape = stack_shape (scalar/0-d when unstacked)
True (per stack element) where the Tucker factors are tied within every sharing group.
The boolean form of
t3_sharing_residual()(residual <= rtol) – a non-enforcing checker with an explicit tolerance (the backend is check-free; frontend safe-mode sites pair the residual withsafety.effective_rtolinstead). Reduce with.all()for a single verdict on a stackedx.Examples
>>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> import t3toolbox.backend.sharing as sharing >>> np.random.seed(0) >>> x = t3.TuckerTensorTrain.randn((6, 6, 5), (3, 3, 2), (1, 2, 2, 1)) >>> tk, tt = x.data >>> print(bool(sharing.t3_tucker_factors_shared(((tk[0], tk[0], tk[2]), tt), (0, 0, 1)))) True >>> print(bool(sharing.t3_tucker_factors_shared(x.data, (0, 0, 1)))) False