Tensor Wrapper

Next topic

Tensor Train Matrices

Tensor Train Vectors¶

class TensorToolbox.core.TTvec(A, store_location='', store_object=None, store_freq=1, store_overwrite=False, multidim_point=None)

Constructor of multidimensional tensor in Tensor Train format [3]

Parameters: A (Candecomp,ndarray,TT,TensorWrapper) – Available input formats are Candecomp, full tensor in numpy.ndarray, Tensor Train structure (list of cores), or a Tensor Wrapper. store_location (string) – Store computed values during construction on the specified file path. The stored values are ttcross_Jinit and the values used in the TensorWrapper. This permits a restart from already computed values. If empty string nothing is done. (method==’ttcross’) store_object (string) – Object to be stored (default are the tensor wrapper and ttcross_Jinit) store_freq (int) – storage frequency. store_freq==1 stores intermediate values at every iteration. The program stores data every store_freq internal iterations. If store_object is a SpectralTensorTrain, then store_freq determines the number of seconds every which to store values. multidim_point (int) – If the object A returns a multidimensional array, then this can be used to define which point to apply ttcross to.
__getitem__(idxs)
build(eps=1e-10, method='svd', rs=None, fix_rank=False, Jinit=None, delta=0.0001, maxit=100, mv_eps=1e-06, mv_maxit=100, kickrank=None)

Common interface for the construction of the approximation.

Parameters: eps (float) – [default == 1e-10] For method==’svd’: precision with which to approximate the input tensor. For method==’ttcross’: TT-rounding tolerance for rank-check. method (string) – ‘svd’ use singular value decomposition to construct the TT representation [3], ‘ttcross’ use low rank skeleton approximation to construct the TT representation [4], ‘ttdmrg’ uses Tensor Train Renormalization Cross to construct the TT representation [5][6], ‘ttdmrgcross’ uses ‘ttdmrg’ with ‘ttcross’ approximation of supercores rs (list) – list of integer ranks of different cores. If None then the incremental TTcross approach will be used. (method==’ttcross’) fix_rank (bool) – determines whether the rank is allowed to be increased (method==’ttcross’) Jinit (list) – list of list of integers containing the r starting columns in the lowrankapprox routine for each core. If None then pick them randomly. (method==’ttcross’) delta (float) – accuracy parameter in the TT-cross routine (method==’ttcross’). It is the relative error in Frobenious norm between two successive iterations. maxit (int) – maximum number of iterations in the lowrankapprox routine (method==’ttcross’) mv_eps (float) – accuracy parameter for each usage of the maxvol algorithm (method==’ttcross’) mv_maxit (int) – maximum number of iterations in the maxvol routine (method==’ttcross’) fix_rank – Whether the rank is allowed to increase kickrank (int) – rank overshooting for ‘ttdmrg’
get_data_F_norm()

Used to get the Frobeniuos norm of the underlying data. This needs to be redefined in QTTvec in order to get the Frobeniuous norm of the real tensor.

get_ttdmrg_real_subtensor(C, idx)

Used to get the real subtensor of the underlying data. This needs to be redefined in QTTvec in order to get the subtensor of the real tensor.

inner_ttcross(rs, Jinit, delta, maxit, mv_eps, mv_maxit, store_init=True)

Construct a TT representation of A using TT cross

Parameters: rs (list) – list of upper ranks (A.ndim) Jinit (list) – list (A.ndim-1) of lists of init indices mv_eps (float) – MaxVol accuracy mv_maxit (int) – maximum number of iterations for MaxVol store_init (bool) – indicates whether to store the init Jinit (see outer_ttcross)
interpolate(Ms=None, eps=1e-08, is_sparse=None)

Interpolates the values of the TTvec at arbitrary points, using the interpolation matrices Ms.

Parameters: Ms (list) – list of interpolation matrices for each dimension. Ms[i].shape[1] == self.shape()[i] eps (float) – tolerance with which to perform the rounding after interpolation is_sparse (list) – is_sparse[i] is a bool indicating whether Ms[i] is sparse or not. If ‘None’ all matrices are non sparse TTvec interpolation TTvec
>>> from DABISpectralToolbox import DABISpectral1D as S1D
>>> Ms = [ S1D.LinearInterpolationMatrix(X[i],XI[i]) for i in range(d) ]
>>> is_sparse = [True]*d
>>> TTapproxI = TTapprox.interpolate(Ms,eps=1e-8,is_sparse=is_sparse)

project(Vs=None, Ws=None, eps=1e-08, is_sparse=None)

Project the TTvec onto a set of basis provided, using the Generalized Vandermonde matrices Vs and weights Ws.

Parameters: Vs (list) – list of generalized Vandermonde matrices for each dimension. Ms[i].shape[1] == self.shape()[i] Ws (list) – list of weights for each dimension. Ws[i].shape[0] == self.shape()[i] eps (float) – tolerance with which to perform the rounding after interpolation is_sparse (list) – is_sparse[i] is a bool indicating whether Ms[i] is sparse or not. If ‘None’ all matrices are non sparse TTvec containting the Fourier coefficients TTvec
>>> from DABISpectralToolbox import DABISpectral1D as S1D
>>> P = S1D.Poly1D(S1D.JACOBI,(0,0))
>>> x,w = S1D.Quadrature(10,S1D.GAUSS)
>>> X = [x]*d
>>> W = [w]*d
>>> # Compute here the TTapprox at points X
>>> TTapprox = TTvec(....)
>>> # Project
>>> Vs = [ P.GradVandermonde1D(x,10,0,norm=False) ] * d
>>> is_sparse = [False]*d
>>> TTfourier = TTapprox.project(Vs,W,eps=1e-8,is_sparse=is_sparse)

rounding(eps)

TT-rounding

rounding2(eps)

TT-rounding

shape()

Returns the shape of the tensor represented

ttcross(eps, rs, Jinit, delta, maxit, mv_eps, mv_maxit, fix_rank=False)

Construct a TT representation of A using TT cross. This routine manage the outer loops for incremental ttcross or passes everything to ttcross if rs are specified.

Parameters: eps (float) – tolerance with which to perform the TT-rounding and check the rank accuracy rs (list) – list of upper ranks (A.ndim) Jinit (list) – list (A.ndim-1) of lists of init indices delta (float) – TT-cross accuracy maxit (int) – maximum number of iterations for ttcross mv_eps (float) – MaxVol accuracy mv_maxit (int) – maximum number of iterations for MaxVol fix_rank (bool) – Whether the rank is allowed to increase
ttdmrg(eps, Jinit, maxit, mv_eps, mv_maxit, kickrank=None, cross=False, store_init=True, loop_detection=False)

Construct a TT representation of A using TT-Density matrix renormalization group

Parameters: eps (float) – Frobenious tolerance of the approximation Jinit (list) – listo (A.ndim-1) of lists of init indices maxit (int) – maximum number of iterations of the ttdmrg mv_eps (float) – MaxVol accuracy mv_maxit (int) – maximum number of iterations for MaxVol kickrank (int) – rank overshooting cross (bool) – if True it uses ttcross for the supercores. If False it uses plain SVD. store_init (bool) – whether to store the initial indices used (restarting from the same indices will lead to the same construction). loop_detection (bool) – whether to check for loops. (Never occurred that we needed it)
ttdmrgcross(eps, Jinit, maxit, mv_eps, mv_maxit, kickrank=None, store_init=True, loop_detection=False)

Construct a TT representation of A using TT-Density matrix renormalization group

Parameters: eps (float) – Frobenious tolerance of the approximation Jinit (list) – listo (A.ndim-1) of lists of init indices maxit (int) – maximum number of iterations of the ttdmrg mv_eps (float) – MaxVol accuracy mv_maxit (int) – maximum number of iterations for MaxVol kickrank (int) – rank overshooting cross (bool) – if True it uses ttcross for the supercores. If False it uses plain SVD. store_init (bool) – whether to store the initial indices used (restarting from the same indices will lead to the same construction). loop_detection (bool) – whether to check for loops. (Never occurred that we needed it)