%feature("docstring") OT::TensorApproximationAlgorithm
"Tensor approximation algorithm.

Available constructors:
    TensorApproximationAlgorithm(*inputSample, outputSample, distribution, functionFactory, nk*)

Parameters
----------
inputSample, outputSample : 2-d sequence of float
    The input random variables :math:`\vect{X}=(X_1, \dots, X_{n_X})^T`
    and the output samples :math:`\vect{Y}` of a model evaluated apart.
distribution : :class:`~openturns.Distribution`
    Joint probability density function :math:`f_{\vect{X}}(\vect{x})`
    of the physical input vector :math:`\vect{X}`.
functionFactory : :class:`~openturns.OrthogonalProductFunctionFactory`
    The basis factory.
degrees : sequence of int
    The size of the basis for each component
    Of size equal to the input dimension.
maxRank : int, optional (default=1)
    The maximum rank

See also
--------
FunctionalChaosAlgorithm, KrigingAlgorithm

Notes
-----
TensorApproximationAlgorithm allows to perform a low-rank approximation in the canonical
tensor format (refer to [Rai2015]_ for other tensor formats and more details).

The canonical tensor approximation of rank :math:`1` reads:

.. math::

    f(X_1, \dots, X_d) = \prod_{j=1}^d v_j^{(1)} (x_j)

The available alternating least-squares algorithm consists in successive approximations
of the coefficients in the basis of the j-th component:

.. math::

    v_j^{(i)} (x_j) = \sum_{k=1}^{n_j} \beta_{j,k}^{(i)} \phi_{j,k} (x_j)

The full canonical tensor approximation of rank :math:`m` reads:

.. math::

    f(X_1, \dots, X_d) = \sum_{i=1}^m \prod_{j=1}^d v_j^{(i)} (x_j)

The decomposition algorithm can be tweaked using the key
`TensorApproximationAlgorithm-DecompositionMethod`.

Examples
--------
>>> import openturns as ot
>>> # Define the model
>>> dim = 1
>>> model = ot.SymbolicFunction(['x'], ['x*sin(x)'])
>>> # Create the input distribution
>>> distribution = ot.ComposedDistribution([ot.Uniform()]*dim)
>>> factoryCollection = [ot.FourierSeriesFactory()] * dim
>>> functionFactory = ot.OrthogonalProductFunctionFactory(factoryCollection)
>>> size = 10
>>> X = distribution.getSample(size)
>>> Y = model(X)
>>> nk = [5] * dim
>>> maxRank = 1
>>> algo = ot.TensorApproximationAlgorithm(X, Y, distribution, functionFactory, nk, maxRank)
>>> algo.run()
>>> result = algo.getResult()"


//The default method used is `GreedyRankOne` from the :class:`~openturns.ResourceMap`
//to approximate coefficients of a given component rank by rank using alternate least-squares.
//Another possible value of `TensorApproximationAlgorithm-Method` is `RankM`
//to approximate all the coefficients across all ranks at the same time.


// ---------------------------------------------------------------------

%feature("docstring") OT::TensorApproximationAlgorithm::run
"Compute the response surface."

// ---------------------------------------------------------------------

%feature("docstring") OT::TensorApproximationAlgorithm::getResult
"Result accessor.

Returns
-------
result : :class:`~openturns.TensorApproximationResult`
    The result of the approximation."

// ---------------------------------------------------------------------

%feature("docstring") OT::TensorApproximationAlgorithm::setMaximumAlternatingLeastSquaresIteration
"Maximum ALS algorithm iteration accessor.

Parameters
----------
maxALSIteration : int
    The maximum number of iterations for the alternating least-squares
    algorithm used for the rank-1 approximation."

// ---------------------------------------------------------------------

%feature("docstring") OT::TensorApproximationAlgorithm::getMaximumAlternatingLeastSquaresIteration
"Maximum ALS algorithm iteration accessor.

Returns
-------
maxALSIteration : int
    The maximum number of iterations for the alternating least-squares
    algorithm used for the rank-1 approximation."

// ---------------------------------------------------------------------

%feature("docstring") OT::TensorApproximationAlgorithm::setMaximumRadiusError
"Maximum radius error accessor.

Parameters
----------
maxRadiusError : float
    Convergence criterion on the radius during alternating least-squares
    algorithm used for the rank-1 approximation."

// ---------------------------------------------------------------------

%feature("docstring") OT::TensorApproximationAlgorithm::getMaximumRadiusError
"Maximum radius error accessor.

Returns
-------
maxRadiusError : float
    Convergence criterion on the radius during alternating least-squares
    algorithm used for the rank-1 approximation."

// ---------------------------------------------------------------------

%feature("docstring") OT::TensorApproximationAlgorithm::setMaximumResidualError
"Maximum residual error accessor.

Parameters
----------
maxResErr : float
    Convergence criterion on the residual during alternating least-squares
    algorithm used for the rank-1 approximation."

// ---------------------------------------------------------------------

%feature("docstring") OT::TensorApproximationAlgorithm::getMaximumResidualError
"Maximum residual error accessor.

Returns
-------
maxResErr : float
    Convergence criterion on the residual during alternating least-squares
    algorithm used for the rank-1 approximation."
