# OrthogonalProductFunctionFactory¶

class OrthogonalProductFunctionFactory(*args)

Base class for orthogonal multivariate functions.

Available constructors:

OrthogonalProductFunctionFactory(functions)

OrthogonalProductFunctionFactory(functions, enumerateFunction)

Parameters:
functions

List of orthogonal univariate function factories with the same dimension as the orthogonal basis.

enumerateFunction`EnumerateFunction`

Associates to an integer its multi-index image in the dimension, which is the dimension of the basis. This multi-index represents the collection of degrees of the univariate polynomials.

Notes

OrthogonalProductFunctionFactory is a particular case of implementation of the `OrthogonalBasis` in the case of polynomial chaos expansion. It provides to the OrthogonalBasis the persistent types of the univariate orthogonal polynomials (e.g. Hermite, Legendre, Laguerre and Jacobi) needed to determine the distribution measure of projection of the input variable. Let’s note that the exact hessian and gradient have been implemented for the product of polynomials. To facilitate the construction of the basis it is recommended to use the class `StandardDistributionPolynomialFactory`.

Examples

```>>> import openturns as ot
>>> from math import pi
>>> funcColl = [ot.HaarWaveletFactory(), ot.FourierSeriesFactory()]
>>> dim = len(funcColl)
>>> enumerateFunction = ot.LinearEnumerateFunction(dim)
>>> productBasis = ot.OrthogonalProductFunctionFactory(funcColl, enumerateFunction)
```

Methods

 `build`(index) Get the term of the basis collection at a given index or multi-indices. Accessor to the object's name. Return the enumerate function. Get the collection of univariate orthogonal function families. Accessor to the object's id. Get the input dimension of the Basis. Get the measure upon which the basis is orthogonal. Accessor to the object's name. Get the output dimension of the Basis. Accessor to the object's shadowed id. Get the size of the Basis. `getSubBasis`(indices) Get a sub-basis of the Basis. Accessor to the object's visibility state. Test if the object is named. Test if the object has a distinguishable name. Tell whether the basis is finite. Tell whether the basis is orthogonal. `setName`(name) Accessor to the object's name. Accessor to the object's shadowed id. `setVisibility`(visible) Accessor to the object's visibility state.
__init__(*args)
build(index)

Get the term of the basis collection at a given index or multi-indices.

Parameters:
indexint

Indicates the term of the basis which must be constructed. In other words, index is used by a bijection from to (with the dimension of the basis). The bijection is detailed in `EnumerateFunction`.

indicessequence of int

Indicates the term of the basis which must be constructed. In other words, indices is used by a bijection from to (with the dimension of the basis). The bijection is the inverse of `EnumerateFunction`.

Returns:
function`Function`

The term of the basis collection at the index index or the inverse of indices.

Examples

```>>> import openturns as ot
>>> # Create an orthogonal basis
>>> polynomialCollection = [ot.LegendreFactory(), ot.LaguerreFactory(), ot.HermiteFactory()]
>>> productBasis = ot.OrthogonalBasis(ot.OrthogonalProductPolynomialFactory(polynomialCollection))
>>> termBasis = productBasis.build(4)
>>> print(termBasis.getEvaluation())
-1.11803 + 3.3541 * x0^2
>>> termBasis = productBasis.build(5)
>>> print(termBasis.getEvaluation())
(1.73205 * x0) * (-1 + x1)
>>> termBasis2 = productBasis.build([1,1,0])
>>> print(termBasis2.getEvaluation())
(1.73205 * x0) * (-1 + x1)
```
getClassName()

Accessor to the object’s name.

Returns:
class_namestr

The object class name (object.__class__.__name__).

getEnumerateFunction()

Return the enumerate function.

Returns:
enumerateFunction`EnumerateFunction`

Enumerate function that translates unidimensional indices into multidimensional indices.

getFunctionFamilyCollection()

Get the collection of univariate orthogonal function families.

Returns:
polynomialFamily

List of orthogonal univariate function families.

getId()

Accessor to the object’s id.

Returns:
idint

Internal unique identifier.

getInputDimension()

Get the input dimension of the Basis.

Returns:
inDimint

Input dimension of the Basis.

getMeasure()

Get the measure upon which the basis is orthogonal.

Returns:
measure`Distribution`

Measure upon which the basis is orthogonal.

Examples

```>>> import openturns as ot
>>> # Create an orthogonal basis
>>> polynomialCollection = [ot.LegendreFactory(), ot.LaguerreFactory(), ot.HermiteFactory()]
>>> productBasis = ot.OrthogonalBasis(ot.OrthogonalProductPolynomialFactory(polynomialCollection))
>>> measure = productBasis.getMeasure()
>>> print(measure.getMarginal(0))
Uniform(a = -1, b = 1)
>>> print(measure.getMarginal(1))
Gamma(k = 1, lambda = 1, gamma = 0)
>>> print(measure.getMarginal(2))
Normal(mu = 0, sigma = 1)
```
getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

getOutputDimension()

Get the output dimension of the Basis.

Returns:
outDimint

Output dimension of the Basis.

Accessor to the object’s shadowed id.

Returns:
idint

Internal unique identifier.

getSize()

Get the size of the Basis.

Returns:
sizeint

Size of the Basis.

getSubBasis(indices)

Get a sub-basis of the Basis.

Parameters:
indiceslist of int

Indices of the terms of the Basis put in the sub-basis.

Returns:
subBasislist of `Function`

Functions defining a sub-basis.

Examples

```>>> import openturns as ot
>>> dimension = 3
>>> input = ['x0', 'x1', 'x2']
>>> functions = []
>>> for i in range(dimension):
...     functions.append(ot.SymbolicFunction(input, [input[i]]))
>>> basis = ot.Basis(functions)
>>> subbasis = basis.getSubBasis([1])
>>> print(subbasis[0].getEvaluation())
[x0,x1,x2]->[x1]
```
getVisibility()

Accessor to the object’s visibility state.

Returns:
visiblebool

Visibility flag.

hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns:
hasVisibleNamebool

True if the name is not empty and not the default one.

isFinite()

Tell whether the basis is finite.

Returns:
isFinitebool

True if the basis is finite.

isOrthogonal()

Tell whether the basis is orthogonal.

Returns:
isOrthogonalbool

True if the basis is orthogonal.

setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

Accessor to the object’s shadowed id.

Parameters:
idint

Internal unique identifier.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters:
visiblebool

Visibility flag.

## Examples using the class¶

Create multivariate functions

Create multivariate functions