A power series class. The Polynomial class provides the standard Python numerical methods '+', '-', '*', '//', '%', 'divmod', '**', and '()' as well as the attributes and methods listed in the `ABCPolyBase` documentation. Parameters ---------- coef : array_like Poly
| 1470 | # |
| 1471 | |
| 1472 | class Polynomial(ABCPolyBase): |
| 1473 | """A power series class. |
| 1474 | |
| 1475 | The Polynomial class provides the standard Python numerical methods |
| 1476 | '+', '-', '*', '//', '%', 'divmod', '**', and '()' as well as the |
| 1477 | attributes and methods listed in the `ABCPolyBase` documentation. |
| 1478 | |
| 1479 | Parameters |
| 1480 | ---------- |
| 1481 | coef : array_like |
| 1482 | Polynomial coefficients in order of increasing degree, i.e., |
| 1483 | ``(1, 2, 3)`` give ``1 + 2*x + 3*x**2``. |
| 1484 | domain : (2,) array_like, optional |
| 1485 | Domain to use. The interval ``[domain[0], domain[1]]`` is mapped |
| 1486 | to the interval ``[window[0], window[1]]`` by shifting and scaling. |
| 1487 | The default value is [-1, 1]. |
| 1488 | window : (2,) array_like, optional |
| 1489 | Window, see `domain` for its use. The default value is [-1, 1]. |
| 1490 | |
| 1491 | .. versionadded:: 1.6.0 |
| 1492 | symbol : str, optional |
| 1493 | Symbol used to represent the independent variable in string |
| 1494 | representations of the polynomial expression, e.g. for printing. |
| 1495 | The symbol must be a valid Python identifier. Default value is 'x'. |
| 1496 | |
| 1497 | .. versionadded:: 1.24 |
| 1498 | |
| 1499 | """ |
| 1500 | # Virtual Functions |
| 1501 | _add = staticmethod(polyadd) |
| 1502 | _sub = staticmethod(polysub) |
| 1503 | _mul = staticmethod(polymul) |
| 1504 | _div = staticmethod(polydiv) |
| 1505 | _pow = staticmethod(polypow) |
| 1506 | _val = staticmethod(polyval) |
| 1507 | _int = staticmethod(polyint) |
| 1508 | _der = staticmethod(polyder) |
| 1509 | _fit = staticmethod(polyfit) |
| 1510 | _line = staticmethod(polyline) |
| 1511 | _roots = staticmethod(polyroots) |
| 1512 | _fromroots = staticmethod(polyfromroots) |
| 1513 | |
| 1514 | # Virtual properties |
| 1515 | domain = np.array(polydomain) |
| 1516 | window = np.array(polydomain) |
| 1517 | basis_name = None |
| 1518 | |
| 1519 | @classmethod |
| 1520 | def _str_term_unicode(cls, i, arg_str): |
| 1521 | if i == '1': |
| 1522 | return f"·{arg_str}" |
| 1523 | else: |
| 1524 | return f"·{arg_str}{i.translate(cls._superscript_mapping)}" |
| 1525 | |
| 1526 | @staticmethod |
| 1527 | def _str_term_ascii(i, arg_str): |
| 1528 | if i == '1': |
| 1529 | return f" {arg_str}" |
no outgoing calls