Refactor polynomial-polynomial addition in the canonical basis.
Following the refactoring of the Grid
and MultiIndexSet
classes, the polynomial-polynomial addition in the canonical basis has been refactored.
The procedure is as follows: match the dimension of the operands, unionize the grid, unionize the multi-index set, sum up the coefficients according to the multi-index set, and create a new instance.
Additionally:
- The concrete implementation of the polynomial-polynomial subtraction in the canonical basis has been removed in favor of using the concrete implementation of addition operation and the
__neg__()
dunder method (i.e., subtraction is an addition between the first operand and the negation of the second operand). - The test suite has been updated to include polynomial-polynomial addition in the canonical basis which is now delegated to the polynomial test module instead of canonical polynomial specific test module.
- The dimension expansion of a polynomial instance to either a target dimension or to a target polynomial instance is now supported by the
expand_dim()
method. The procedure also makes sure that the underlying user and internal domains are expanded accordingly. Exceptions will be raised if they are incompatible. - Introduce
__len__()
method to compute the number of polynomials within an instance (note that a single polynomial instance may contain multiple coefficient sets).
This MR should resolve Issue #161 (closed) and part of extending the support for arithmetic operations involving polynomial (see Issue #142 (closed)).