TuckerTensorTrain.has_numerically_minimal_ranks#
- t3toolbox.tucker_tensor_train.TuckerTensorTrain.has_numerically_minimal_ranks(rtol=1e-09)#
def has_numerically_minimal_ranks(self, rtol: float = 1e-9) -> bool:
True if the ranks are numerically minimal: no stored rank is numerically redundant.
Distinct from
has_minimal_ranks, which is structural (ranks equal the structural minimum). A tensor can be structurally minimal yet have a near-zero singular value at some rank boundary (numerically redundant); this catches that. Algorithm: the cheap structural check first (structural redundancy implies numerical redundancy), then – only if structurally minimal – ant3svd()at relative tolerancertoland a comparison of the truncated ranks to the stored ranks. Thet3svdmakes this O(tensor) – a diagnostic, not a hot-path check.For an orthonormal frame prefer
T3Frame.has_numerically_minimal_ranks(), which needs no SVD (orthonormal cores are full-rank, so structurally-minimal => numerically-minimal).Examples
>>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> np.random.seed(0) >>> x = t3.TuckerTensorTrain.randn((6, 7, 5), (2, 2, 2), (1, 2, 2, 1)) >>> print(x.has_minimal_ranks, x.has_numerically_minimal_ranks()) # full-rank random tensor True True >>> xbig = x.resize((6, 7, 5), (3, 2, 2), (1, 2, 2, 1)) # tucker_0 padded -> a redundant rank >>> print(xbig.has_minimal_ranks, xbig.has_numerically_minimal_ranks()) False False
- Parameters:
rtol (float)
- Return type:
bool