Add a MultiIndexSet method to make an instance downward-closed
As part of the refactoring and update of the MultiIndexSet
class (see Issue #99 (closed)), especially in relation to the separation between the notion of completeness and downward-closedness (see Issue #105 (closed)), a method to make an instance of MultiIndexSet
downward-closed should be added to the class. This method (possibly called make_downward_closed()
is parallel to the method make_complete()
(see Issue #103 (closed)).
Here's an example of how it might be used:
>>> import numpy as np
>>> import minterpy as mp
>>> exponents = np.array([
... [0, 1, 0],
... [1, 0, 1],
... ])
>>> mi = mp.MultiIndexSet(exponents, lp_degree=1.0)
>>> mi.is_downward_closed # See Issue #105
False
>>> mi_downward_closed = mi.make_downward_closed() # By default, outplace modification
>>> mi_downward_closed
MultiIndexSet
[[0 0 0] # new element
[1 0 0] # new element
[0 1 0]
[0 0 1] # new element
[1 0 1]]
>>> mi_downward_closed.is_downward_closed
True
Here, three new elements are added to the multi-index set such that the resulting set downward-closed. The resulting set is sorted lexicographically.
Similar to make_complete()
, the current instance may be modified in-place as follows:
>>> mi.make_downward_closed(inplace=True)
>>> mi.is_downward_closed
True
>>> mi
MultiIndexSet
[[0 0 0] # new element
[1 0 0] # new element
[0 1 0]
[0 0 1] # new element
[1 0 1]]
As discussed in Issue #105 (closed), downward-closed multi-index set may not be complete.
For instance, the complete multi-index set of three-dimensional polynomial with respect to l_p
-degree 1.0 having a polynomial degree of:
>>> mi.poly_degree
2
is:
>>> mp.MultiIndexSet.from_degree(3, 2, 1.0)
MultiIndexSet
[[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]
[0 0 2]]
From the above complete set there are many several possible downward-closed sets; The DDS algorithm only requires a downward-closed set.