Create a Multi-Index Set#
import minterpy as mp
import numpy as np
A Minterpy polynomial is defined with respect to a multi-index set; the set defines the polynomial exponents across different spatial dimensions. This guide provides an example on how-to construct a multi-index set in Minterpy using different constructors.
Currently, Minterpy supports the creation of a multi-index set via two constructors:
minterpy.MultiIndexSet.from_degree()is used to create a complete multi-index set with a given spatial dimension, polynomial degree, and -degreeminterpy.MultiIndexSet()(the default constructor) is used to create a multi-index set with a given set of exponents and -degree
From a given spatial dimension, polynomial degree, and -degree#
The constructor minterpy.MultiIndexSet.from_degree() can be used to create a complete multi-index set for a given spatial dimension, degree, and
spatial_dimension: the number of spatial dimensions ( ) of the multi-index set (must be an integer )poly_degree: the polynomial degree ( ) of the multi-index set (must be an integer )lp_degree: the degree of the -norm of the multi-index set (optional but must be a positive float; if not given, a default value of is used)
Note
The set constructed via from_degree() constructor is complete in the sense that it contains all the exponents
Suppose we would like to create a multi-index set of spatial dimension
mi = mp.MultiIndexSet.from_degree(3, 2)
The resulting multi-index set can be printed to the terminal:
print(mi)
MultiIndexSet(m=3, n=2, p=2.0)
[[0 0 0]
[1 0 0]
[2 0 0]
[0 1 0]
[1 1 0]
[0 2 0]
[0 0 1]
[1 0 1]
[0 1 1]
[1 1 1]
[0 0 2]]
Note
The string produced by calling print() includes the number m, n, and p. In Minterpy these are the symbols conventionally used to represent spatial dimension, polynomial degree, and
The MultiIndexSet instance stores the exponents in the exponents property:
print(mi.exponents)
[[0 0 0]
[1 0 0]
[2 0 0]
[0 1 0]
[1 1 0]
[0 2 0]
[0 0 1]
[1 0 1]
[0 1 1]
[1 1 1]
[0 0 2]]
The exponents property is a NumPy integer array with the given spatial dimension as the number of columns. The first column corresponds to the exponents of polynomial basis of the first dimension, the second column the second dimension, etc.
The number of elements of the resulting multi-index set is determined by the choice of the parameters such that the resulting set is complete. In the example above, the set contains all the exponents
From a given set of exponents and -degree#
Alternatively, a MultiIndexSet instance can be constructed by passing a set of exponents and the corresponding minterpy.MultiIndexSet()). The set of exponents must be given as a NumPy integer array.
Suppose we would like to create a multi-index set with the following exponents:
having
Create and store the exponents as a NumPy integer array:
exps = np.array([[0, 0], [1, 0], [0, 1], [0, 2], [0, 3]], dtype=int)
exps
array([[0, 0],
[1, 0],
[0, 1],
[0, 2],
[0, 3]])
mi = mp.MultiIndexSet(exps, lp_degree=1.0)
Verify that the resulting MultiIndexSet instance has the exponents as given:
print(mi)
MultiIndexSet(m=2, n=3, p=1.0)
[[0 0]
[1 0]
[0 1]
[0 2]
[0 3]]
…and the
print(mi.lp_degree)
1.0
Notice that the resulting multi-index set has its exponents lexicographically sorted.
The spatial dimension of the multi-index set is inferred from the given exponents (i.e., the number of columns of the exponents):
print(mi.spatial_dimension)
2
The polynomial degree of the multi-index set is also inferred from the given exponents and the
print(mi.poly_degree)
3
The number above corresponds the smallest degree
Note
When the default constructor is used to create an instance of MultiIndexSet, the