t3toolbox.manifold.manifold_dim#
- t3toolbox.manifold.manifold_dim(s=t3.T3Structure) int#
Get the dimension of the fixed rank T3 manifold with a given structure.
Examples
>>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> import t3toolbox.manifold as t3m >>> s = ((15,16,13), (9,10,8), (2,7,6,3)) >>> mdim = t3m.manifold_dim(s) >>> print(mdim) 578
In the following more detailed example, we verify that the manifold dim is correct by generating an excessive number of random dense tangent vectors and performing an SVD on them. The number of nonzero singular values is the dimension of the tangent space, which is the dimension of the manifold.
>>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> import t3toolbox.manifold as t3m >>> import t3toolbox.basis_coordinates_format as bvf >>> import t3toolbox.orthogonalization as orth >>> s = ((5,6,3), (5,3,2), (2,2,4,1)) >>> mdim = t3m.manifold_dim(s) >>> print(mdim) 29 >>> p = t3.t3_corewise_randn(s) >>> base, _ = orth.orthogonal_representations(p) >>> tucker_shapes, tt_shapes = bvf.get_base_hole_shapes(base) >>> num_tucker_entries = np.sum([np.prod(shape) for shape in tucker_shapes]) >>> num_tt_entries = np.sum([np.prod(shape) for shape in tt_shapes]) >>> num_core_entries = num_tucker_entries + num_tt_entries >>> print(num_core_entries) 80 >>> vv = [t3m.tangent_randn(base, apply_gauge_projection=False) for _ in range(num_core_entries)] >>> dense_vv = np.stack([t3m.tangent_to_dense(v, base) for v in vv]) >>> _, ss, _ = np.linalg.svd(dense_vv.reshape((num_core_entries,-1)), full_matrices=False) >>> print(ss[mdim-1]) # last nonzero singular value 2.8197268462367813 >>> print(ss[mdim]) # first zero singular value 1.1933078683104488e-14