Skip to content

Multi-index sets

index_set

Multi-index sets and related functions for polynomial spaces.

This module contains functions for creating multi-index sets. Mathematically, a multi-index set \(\Lambda \subset \mathbb{N}_0^d\) is a set of multi-indices \(\lambda = (\lambda_1, \ldots, \lambda_d)\), where \(\lambda_i \in \mathbb{N}_0\) for all \(i = 1, \ldots, d\). Using these multi-indices, we can define tensorized basis functions

\[ \begin{equation} P_\lambda(x) = \prod_{i=1}^d P_{\lambda_i}(x_i), \quad x \in \mathbb{R}^d, \end{equation} \]

and span polynomial spaces conveniently via \(\text{span}\{P_\lambda: \lambda \in \Lambda\}\). The module supports three types of multi-index sets: tensor product (TP), total degree (TD), and hyperbolic cross (HC). It also contains utility functions for manipulating and checking admissibility of index sets.

Functions:

Name Description
cartesian_product

Returns the Cartesian product of input arrays.

generate_index_set

Generates a multi-index set of a given type.

get_lower_neighbours

Returns the lower neighbours of an index.

get_upper_neighbours

Returns the upper neighbours of an index.

is_downward_closed

Checks if the given multi-index set is downward closed.

separate_index

Separates an adaptive multi-index.

slice_index_set

Slices an adaptive index set along a level.

binary_expansion

Generates the binary expansion of an index.

union_binary_expansions

Generates a union of binary expansions of an sliced index set.

multichaos.index_set.cartesian_product

cartesian_product(*arrays: tuple[np.ndarray]) -> np.ndarray

Returns the Cartesian product of input arrays.

Parameters:

Name Type Description Default
arrays tuple

Arrays to be combined.

()

Returns:

Type Description
np.ndarray

Cartesian product of input arrays.

multichaos.index_set.generate_index_set

generate_index_set(index_set_type: Literal['TP', 'TD', 'HC'], max_degree: int, dim: int) -> np.ndarray

Generates a multi-index set of a given type.

The supported types are tensor product (TP), total degree (TD), and hyperbolic cross (HC).

Parameters:

Name Type Description Default
index_set_type Literal["TP", "TD", "HC]

Type of the index set.

required
max_degree int

Maximum degree of the index set.

required
dim int

Dimension of the index set.

required

Returns:

Type Description
np.ndarray

Multi-index set

multichaos.index_set.get_lower_neighbours

get_lower_neighbours(index: list) -> Generator[list, None, None]

Returns the lower neighbours of index.

A lower neighbour is defined as a tuple that differs in exactly one entry by subtracting one.

Parameters:

Name Type Description Default
index list

Multi-index to find lower neighbours for.

required

Yields:

Type Description
list

Generator of lower neighbours.

multichaos.index_set.get_upper_neighbours

get_upper_neighbours(index: list) -> Generator[list, None, None]

Returns the upper neighbours of index.

An upper neighbour is defined as a tuple that differs in exactly one entry by adding one.

Parameters:

Name Type Description Default
index list

Multi-index to find upper neighbours for.

required

Yields:

Type Description
list

Generator of upper neighbours.

multichaos.index_set.is_downward_closed

is_downward_closed(index_set: np.ndarray) -> bool

Checks if the given multi-index set is downward closed.

A multi-index set \(\Lambda \subset \mathbb{N}_0^d\) is downward closed if \(\lambda \in \Lambda \Rightarrow \mu \in \Lambda\) for all \(\mu \in \mathbb{N}_0^d\) for which \(\mu \leq \lambda\) componentwise.

Parameters:

Name Type Description Default
index_set np.ndarray

Multi-index set to be checked.

required

Returns:

Type Description
bool

True if the index set is downward closed, False otherwise.

multichaos.index_set.separate_index

separate_index(index: list) -> tuple[list, int]

Separates an adaptive multi-index.

This function simply separates an index \((k, l) = \lambda \in \mathbb{N}_0^{d + 1}\) into \(k \in \mathbb{N}_0^d\) and \(l \in \mathbb{N}_0\).

Parameters:

Name Type Description Default
index list

Multi-index to be separated.

required

Returns:

Type Description
tuple

Separated multi-index.

multichaos.index_set.slice_index_set

slice_index_set(index_set: list, l: int) -> list

Slices an adaptive index set along a level.

Given an adaptive index set \(\Lambda \subset \mathbb{N}_0^{d + 1}\) and level \(l \in \mathbb{N}_0\), this returns \(\{(k, l') \in \Lambda : l' = l\}\).

Parameters:

Name Type Description Default
index_set list

Adaptive index set to be sliced.

required
l int

Level to slice along.

required

Returns:

Type Description
np.ndarray

Sliced index set

multichaos.index_set.binary_expansion

binary_expansion(index: list) -> list

Generates the binary expansion of an index.

If index denotes \(\lambda \in \mathbb{R}^d\), this returns all multi-indices \(k \in \mathbb{R}^d\) for which it holds

\[ 2^k \leq \lambda < 2^{k+1} - 1. \]

The size comparison is element-wise.

Parameters:

Name Type Description Default
index list

Multi-index to be checked.

required

Returns:

Type Description
list

List of multi-indices that satisfy the condition.

multichaos.index_set.union_binary_expansions

union_binary_expansions(index_set: list, l: int) -> list

Generates a union of binary expansions of a sliced index set.

This returns the index set given by the binary expansion of all indices in the level \(l\)-sliced index set.