t3toolbox.basis_coordinates_format.bc_to_t3#

t3toolbox.basis_coordinates_format.bc_to_t3(ii: int, use_tt_coord: bool, basis: T3Basis, coords: T3Coordinates) t3toolbox.tucker_tensor_train.TuckerTensorTrain#

Convert basis-coordinates representation to TuckerTensorTrain.

If replacement_ind=1, replace_tt=True:

1 -- L0 --(H1)-- R2 -- R3 -- 1
     |     |     |     |
     U0    U1    U2    U3
     |     |     |     |

If replacement_ind=2, replace_tt=False:

1 -- L0 -- L1 -- O2 -- R3 -- 1
     |     |     |     |
     U0    U1   (V2)   U3
     |     |     |     |
Parameters:
  • ii (int) – Index of coordinate. 0 <= replacement_ind < num_cores

  • replace_tt (bool) – Indicates whether to use TT coordinate (True) or a Tucker coordinate (False)

  • base (T3Basis) – Basis cores

  • coords (T3Coordinates) – Coordinate cores

Raises:

RuntimeError

  • Error raised if the basis and coordinates do not fit with each other

Examples

>>> import numpy as np
>>> import t3toolbox.basis_coordinates_format as bcf
>>> randn = np.random.randn # shorthand
>>> (U0,U1,U2) = (randn(10, 14), randn(11, 15), randn(12, 16))
>>> (L0,L1,L2) = (randn(1, 10, 2), randn(2, 11, 3), randn(3,12,4))
>>> (R0,R1,R2) = (randn(2,10,4), randn(4, 11, 5), randn(5, 12, 1))
>>> (O0,O1,O2) = (randn(1, 9, 4), randn(2, 8, 5), randn(3, 7, 1))
>>> base = bcf.T3Basis((U0,U1,U2), (L0,L1,L2), (R0,R1,R2), (O0,O1,O2))
>>> (V0,V1,V2) = (randn(9,14), randn(8,15), randn(7,16))
>>> (H0,H1,H2) = (randn(1,10,4), randn(2,11,5), randn(3,12,1))
>>> coords = bcf.T3Coordinates((V0,V1,V2), (H0,H1,H2))
>>> ((B0, B1, B2), (G0, G1, G2)) = bcf.bc_to_t3(1, True, base, coords).data # replace index-1 TT-backend
>>> print(((B0,B1,B2), (G0,G1,G2)) == ((U0,U1,U2), (L0,H1,R2)))
True
>>> ((B0, B1, B2), (G0, G1, G2)) = bcf.bc_to_t3(1, False, base, coords).data # replace index-1 tucker backend
>>> print(((B0,B1,B2), (G0,G1,G2)) == ((U0,V1,U2), (L0,O1,R2)))
True