Implement multiplication method for Grid instances
Multiplication shall also be implemented for the underlying Grid instances. Previously, multiplication is already implemented for multi-index set of exponents (Issue #119 (closed)).
The multiplication between two instances of Grid
instances means:
- multiply the underlying multi-index set that results in a new multi-index set.
- create a new instance of
Grid
with the new multi-index set.
Inplace multiplication will not be implemented for the time being as it will create another level of complexity in the codebase to maintain the mutability of an instance. This issue assumes that multiplying two instances of Grid
will return a new instance of Grid
.
This issue is part of the Grid
class update and refactoring (see Issue #135).
Implementation details
A common operation that appears in multiplication, addition, and dimension expansion is "merging". A merging is defined by creating a new instance of Grid
with a new multi-index set as long as the underlying generating functions and points of the two instances are compatible:
- If the generating functions are available in both instances and they are compatible: create a new instance with the given multi-index set and the generating function
- If the generating functions are available in both instances and they are incompatible: raise an exception. There is no reference to which the grids can be merged
- If there is no generating function and the generating points are compatible: create a new instance with the given multi-index set and the larger generating points
- If there is no generating function and the generating points are incompatible: raise an exception. There is no reference to which the grids can be merged
Via merging, the difference between dimension expansion, multiplication, and addition is the multi-index set used to create the merged instance.
The bigger picture
Allowing the multiplication between instances of Grid
will improve the encapsulation within the polynomial-polynomial multiplication (see, for instance, Issue #143 (closed) for polynomials in the Newton basis).
Multiplication between polynomials then means:
- Expand the dimension of the polynomial whose the lower dimension
- Multiply the underlying
Grid
instances - Multiply the underlying
MultiIndexSet
instances if they are not the same as the one attached to theGrid
instance - Process the coefficients according to the basis (note that multiplication in different bases may yield a different procedure to process the resulting coefficients)
- Create a new instance of polynomial with the new
Grid
instance, coefficients, and (when applicable)MultiIndexSet
instance.