polynomials
===========

.. py:module:: polynomials


Classes
-------

.. autoapisummary::

   polynomials.Pijk


Functions
---------

.. autoapisummary::

   polynomials.polynomial_product_matrix


Module Contents
---------------

.. py:class:: Pijk(data: collections.abc.Mapping[tuple[int, int, int], jaxoplanet.types.Array], degree: int = None)

   Bases: :py:obj:`equinox.Module`


   A class to represent and manipulate spherical harmonics in the
   polynomial basis. Several indices are used throughout the class:

   * Indices :math:`(i, j, k)` represent the order of the polynomials of
     :math:`(x, y, z)`, for example :math:`(1, 0, 2)` represents :math:`x\,z^2`.

   * Indices :math:`(l, m)` represent the orders of the spherical harmonics.

   * Index n represent the index of the polynomial in the flattened array.

   Flattened array ``todense`` and ``from_dense`` follow the convention from
   Luger et al. (2019). More specifically:

   .. math::

       \tilde{p} =
       \begin{pmatrix}
           1 & x & y & z & x^2 & xz & xy & yz & y^2 &
           \cdot\cdot\cdot
       \end{pmatrix}^\mathsf{T}



   .. py:attribute:: data
      :type:  dict[tuple[int, int, int], jaxoplanet.types.Array]


   .. py:attribute:: degree
      :type:  int


   .. py:attribute:: diagonal
      :type:  bool


   .. py:property:: shape


   .. py:property:: indices


   .. py:method:: ijk2lm(i, j, k)
      :staticmethod:



   .. py:method:: n2lm(n)
      :staticmethod:



   .. py:method:: lm2n(l, m)
      :staticmethod:



   .. py:method:: lm2ijk(l, m)
      :staticmethod:



   .. py:method:: n2ijk(n)
      :staticmethod:



   .. py:method:: index(i, j, k)


   .. py:method:: tosparse() -> jax.experimental.sparse.BCOO


   .. py:method:: todense() -> jaxoplanet.types.Array


   .. py:method:: from_dense(x: jaxoplanet.types.Array, degree: int = None) -> Pijk
      :classmethod:



   .. py:method:: __add__(other: Pijk) -> Pijk


   .. py:method:: __mul__(other: Any) -> Pijk


   .. py:method:: __rmul__(other: Any) -> Pijk


   .. py:method:: __getitem__(key) -> jaxoplanet.types.Array


.. py:function:: polynomial_product_matrix(p, degree)

   Given a polynomial vector p, return a matrix M such that M @ p2 is the polynomial
   product of p with p2.

   Note: This function was implemented to reproduce the filter matrix from starry.
   However, tests show that using the polynomial multiplication operator on the class
   is faster than introducing a matrix multiplication (see surface_light_curve.py).

   :param p: A vector in the polynomial basis (in its dense form).
   :type p: Array
   :param degree: Degree of the polynomial to be multiplied with.
   :type degree: int

   :returns: The polynomial product matrix.
   :rtype: Array


