Previous topic

Tensor Train Matrices

Next topic

Quantics Tensor Train Matrices

This Page

Quantics Tensor Train Vectors

class TensorToolbox.core.QTTvec(A, global_shape=None, base=2, store_location='', store_object=None, store_freq=1, store_overwrite=False, multidim_point=None)

Constructor of multidimensional tensor in Quantics Tensor Train format [1][2].

Parameters:
  • A (ndarray,TensorWrapper,TT) – Available input formats are full tensor in numpy.ndarray, Tensor Wrapper, Tensor Train structure (list of cores)
  • global_shape (list) – Argument to be provided if A is the list of cores of a TT format.
  • base (int) – base selected to do the folding
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.

get_folded_shape()

Return the shape of the folded tensor (list of lists)

get_global_ndim()

Return the ndim of the original tensor

get_global_shape()

Return the shape of the original tensor

get_q_shape()

Return the shape of the base “base” shape of the tensor

get_ttdmrg_real_subtensor(C, idxs)

Used to get the Frobeniuos norm of a subtensor of the underlying data.

Parameters:
  • C (np.ndarray) – Extracted 4-d tensor with shape len(l_idx) x n x m x len(r_idx)
  • idxs (list) – List of tuples of the form (l_idx, slice, slice, r_idx)
Return np.ndarray Creal:
 

1-d array containing the filtered values belonging to the real tensor

interpolate(Ms=None, eps=1e-08, is_sparse=None)

Interpolates the values of the QTTvec 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 [sparsity is not exploited]
Returns:

QTTvec interpolation

Return type:

QTTvec

>>> 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 QTTvec 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 [sparsity is not exploited]
Returns:

TTvec containting the Fourier coefficients

Return type:

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 = QTTvec(....)
>>> # 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)
q_to_global(idxs)

This is a non-injective function from the q indices to the global indices