Previous topic

Weighted Tensor Train Vectors

Next topic

Multi-linear algebra

This Page

Spectral Tensor Train

class TensorToolbox.core.STT(f, grids, params, range_dim=0, marshal_f=True, surrogateONOFF=False, surrogate_type=None, orders=None, orderAdapt=None, eps=0.0001, method='ttdmrg', rs=None, fix_rank=False, Jinit=None, delta=0.0001, maxit=100, mv_eps=1e-06, mv_maxit=100, kickrank=None, store_location='', store_overwrite=False, store_freq=0)

Constructor of the Spectral Tensor Train approximation [7]. 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.

  • f (function) – multidimensional function to be approximated with format f(x,theta,params)
  • grids (list) – this is a list with len(grids)=dim(Is)+dim(It) which can contain: a) 1-dimensional numpy.array of points discretizing the i-th dimension, b) a tuple (PolyType,QuadType,PolyParams,span) where PolyType is one of the polynomials available in SpectralToolbox.Spectral1D and QuadType is one of the quadrature rules associated to the selected polynomial and PolyParams are the parameters for the selected polynomial. span is a tuple defining the left and right end for dimension i (Example: (-3,np.inf)) c) a tuple (QuadType,span) where QuadType is one of the quadrature rules available in SpectralToolbox.Spectral1D without the selection of a particular polynomial type, and span is defined as above.
  • params (object) – any list of parameters to be passed to the function f
  • range_dim (int) – define the dimension of the spatial dimension Is. For functionals f(theta,params), dim(Is)=0. For scalar fileds in 3D, dim(Is)=3.
  • marshal_f (bool) – whether to marshal the function f or not. For MPI support, the function f must be marshalable (does this adverb exists??).
  • surrogateONOFF (bool) – whether to construct the surrogate or not
  • surrogate_type (str) – whether the surrogate will be an interpolating surrogate (TensorTrain.LINEAR_INTERPOLATION or TensorTrain.LAGRANGE_INTERPOLATION) or a projection surrogate (TensorTrain.PROJECTION)
  • orders (list) – polynomial orders for each dimension if TensorTrain.PROJECTION is used. If orderAdapt==True then the orders are starting orders that can be increased as needed by the construction algorithm. If this parameter is not provided but orderAdapt==True, then the starting order is 1 for all the dimensions.
  • orderAdapt (bool) – whether the order is fixed or not.
  • stt_store_location (str) – path to a file where function evaluations can be stored and used in order to restart the construction.
  • stt_store_overwrite (bool) – whether to overwrite pre-existing files
  • stt_store_freq (int) – storage frequency. Determines every how many seconds the state is stored. stt_store_freq==0 stores every time it is possible.
  • empty (bool) – Creates an instance without initializing it. All the content can be initialized using the setstate() function.


For a description of the remaining parameters see TTvec.

__call__(x_in, verbose=False)

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,:]

Compute the integral of the approximated function

Returns:an array with dimension equal to the space dimension (range_dim), containing the value of the integral.

Prepares the TTapprox from the generic_approx


Upgrade to v0.3.0

Parameters:filename (string) – path to the filename. This must be the main filename with no extension.