Add Support for Polynomial-Polynomial Addition/Subtraction in the Chebyshev Basis
Currently, Minterpy does not yet support addition/subtraction operation between polynomials in the Chebyshev basis. To have a more consistent feature set of polynomials across different bases, this feature shall be implemented.
The logic behind the addition or subtraction is as follows: Given two polynomials in the Chebyshev basis
- Verify the type, length, and dimension of the operands; match their dimension if necessary
- Add the underlying
Grid
instances (rely on the method of unionizing twoGrid
instances; see Issue #155 (closed)) - Add the underlying
MultiIndexSet
instances if they are not the same as the one attached to the respective instances (this is related to the notion "separate indices"). Adding twoMultiIndexSet
instances rely on the union method (see Issue #124 (closed)) - Process the coefficients; match the multi-index set elements and sum the coefficients of the matching elements. This procedure is similar to the coefficients processing of polynomial-polynomial addition in the canonical basis (see Issue #161 (closed)).
- Create a new instance of polynomial with the new
Grid
instance, coefficients, and (when applicable)MultiIndexSet
instance.
Subtraction uses the same procedure as addition but with the negated instance of the other operand (__neg__()
).
Note that the Grid
instance is not strictly a requirement for a polynomial in the Chebyshev basis as its definition does not rely on the notion of interpolation grid (similar to the canonical basis, unlike the Newton or Lagrange basis). However, such instance must still be processed properly to support the transformation from the Chebyshev basis to another basis in Minterpy.
This approach shall follow the recent changes in the MultiIndexSet
(see Issue #99 (closed)) and Grid
(see Issue #135) classes.
This issue is part of extending the support for arithmetic operations involving polynomial (see Issue #142 (closed)).