Find the index corresponding to the unfolded (flat) version of a tensor
Parameters: |
|
---|---|
Returns: | index for the flatten tensor |
Find the index corresponding to the folded version of a tensor from the flatten version
Parameters: |
|
---|---|
Returns: | list of int – the index for the folded version |
Note: | this routine can be used to get the indexes of a TTmat from indices of a matkron (matrix obtained using np.kron): (i,j) in N^d x N^d -> ((i_1,..,i_d),(j_1,..,j_d)) in (N x .. x N) x (N x .. x N) |
From a tuple of indicies, apply all the unslicing transformations and restore the fixed indices in order to extract values from a tensor with a certain ghost_shape. If ghost_shape==None, fix_dims==None and fix_idxs==None, then this performs only an unslicing of the index and it is assumed ghost_shape=shape.
Parameters: |
|
---|---|
Returns: | tuple (lidxs,out_shape,transpose_list_shape). lidxs is an iterator of the indices. out_shape is a tuple containing the shape of the output tensor. transpose_list_shape is a flag indicating whether the output format need to be transposed (behaving accordingly to np.ndarray). |
This function reshapes a 2D-matrix obtained as kron product of len(nrows)==len(ncols) matrices, to a len(nrows)-tensor that can be used as input for the TTmat constructor. Applies the Van Loan-Pitsianis reordering of the matrix elements.
Parameters: |
|
---|
Mapping from the multidimensional matrix indexing to the tt matrix indexing
(rowidxs,colidxs) = ((i_1,...,i_d),(j_1,...,j_d)) -> (l_1,...,l_d)
Parameters: |
|
---|---|
Returns: | tuple,int indices in the tt format |
Mapping from the tt matrix indexing to the multidimensional matrix indexing
(l_1,...,l_d) -> (rowidxs,colidxs) = ((i_1,...,i_d),(j_1,...,j_d))
Parameters: |
|
---|---|
Returns: | (rowidxs,colidxs) = ((i_1,..,i_d),(j_1,..,j_d)) indices in the matrix indexing |
Find the rxr submatrix of maximal volume in A(nxr), n>=r
Parameters: | |
---|---|
Returns: | (I,AsqInv,it) where I is the list or rows of A forming the matrix with maximal volume, AsqInv is the inverse of the matrix with maximal volume and it is the number of iterations to convergence |
Raises: | raise exception if the dimension of A is r>n or if A is singular |
Raises: | ConvergenceError if convergence is not reached in maxit iterations |
Given a matrix A nxm, find the maximum volume submatrix with rank r<n,m.
Parameters: |
|
---|---|
Parma int maxvolit: | |
maximum number of iterations in the maxvol routine |
|
Returns: | (I,J,AsqInv,it) where I and J are the list of rows and columns of A that compose the submatrix of maximal volume, AsqInv is the inverse of such matrix and it is the number of iteration to convergence |
Golub-Kahan reorthogonalization
Used to load TensorToolbox data.
Parameters: |
---|
Constructor of objects that can be stored
Parameters: |
---|
Used to load additional data in hdf5 format. To be redefined in subclasses.
Used to store additional data in hdf5 format. To be redefined in subclasses.
Used to load additional data.
Set a new store frequency for the object
Parameters: | store_freq (int) – new store location |
---|
Set a new store location for the object
Parameters: | store_location (string) – new store location |
---|
Used to store the computed values of a TTcross approximation. Usually needed when the single function evaluation is demanding or when we need to restart TTcross later on.
Parameters: |
|
---|
Deprecated since version 0.3.0: Use the objects’ methods store().
Used to upgrade the storage version from version <0.3.0 to version 0.3.0
Parameters: | filename (string) – path to the filename. This must be the main filename with no extension. |
---|
Returns the rank-1 multidimensional random vector in Tensor Train format
Returns the rank-1 multidimensional vector of zeros in Tensor Train format
Returns the multidimensional identity operator in Tensor Train format
Returns the rank-1 multidimensional random matrix in Tensor Train format
Returns the rank-1 multidimensional vector of zeros in Quantics Tensor Train format
Constructor of the Spectral Quantics Tensor Train approximation. Given a function f(x,theta,params):(Is, It) -> R with dim(Is)=n and dim(It)=d, construct an approximation of g(theta,params): It -> h_t(Is). For example Is could be the discretization of a spatial dimension, and It some parameter space, so that f(x,theta,params) describes a scalar field depending some parameters that vary in It. The params in the definition of f can be constants used by the function or othere objects that must be passed to the function definition.
Parameters: |
|
---|
Note
For a description of the remaining parameters see TTvec.
Evaluate the surrogate on points x_in
Parameters: | x_in (np.ndarray) – 1 or 2 dimensional array of points in the parameter space where to evaluate the function. In 2 dimensions, each row is an entry, i.e. x_in.shape[1] == self.param_dim |
---|---|
Returns: | an array with dimension equal to the space dimension (range_dim) plus one. If A is the returned vector and range_dim=2, then A[i,:,:] is the value of the surrogate for x_in[i,:] |