/ lib / numpy / polynomial / hermite_e.pyc
hermite_e.pyc
   1  o

   2  [��c'��@svdZddlZddlmZddlmZddlm	Z
   3  ddlmZgd�Z
e
   4  jZdd	�Zd
   5  d�Ze�ddg�Ze�dg�Ze�dg�Ze�ddg�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdBdd�ZdCdd�Zdgdddfd d!�Z dDd#d$�Z!d%d&�Z"d'd(�Z#d)d*�Z$d+d,�Z%d-d.�Z&d/d0�Z'd1d2�Z(dEd4d5�Z)d6d7�Z*d8d9�Z+d:d;�Z,d<d=�Z-d>d?�Z.Gd@dA�dAe�Z/dS)Fa.
   6  ===================================================================
   7  HermiteE Series, "Probabilists" (:mod:`numpy.polynomial.hermite_e`)
   8  ===================================================================
   9  
  10  This module provides a number of objects (mostly functions) useful for
  11  dealing with Hermite_e series, including a `HermiteE` class that
  12  encapsulates the usual arithmetic operations.  (General information
  13  on how this module represents and works with such polynomials is in the
  14  docstring for its "parent" sub-package, `numpy.polynomial`).
  15  
  16  Classes
  17  -------
  18  .. autosummary::
  19     :toctree: generated/
  20  
  21     HermiteE
  22  
  23  Constants
  24  ---------
  25  .. autosummary::
  26     :toctree: generated/
  27  
  28     hermedomain
  29     hermezero
  30     hermeone
  31     hermex
  32  
  33  Arithmetic
  34  ----------
  35  .. autosummary::
  36     :toctree: generated/
  37  
  38     hermeadd
  39     hermesub
  40     hermemulx
  41     hermemul
  42     hermediv
  43     hermepow
  44     hermeval
  45     hermeval2d
  46     hermeval3d
  47     hermegrid2d
  48     hermegrid3d
  49  
  50  Calculus
  51  --------
  52  .. autosummary::
  53     :toctree: generated/
  54  
  55     hermeder
  56     hermeint
  57  
  58  Misc Functions
  59  --------------
  60  .. autosummary::
  61     :toctree: generated/
  62  
  63     hermefromroots
  64     hermeroots
  65     hermevander
  66     hermevander2d
  67     hermevander3d
  68     hermegauss
  69     hermeweight
  70     hermecompanion
  71     hermefit
  72     hermetrim
  73     hermeline
  74     herme2poly
  75     poly2herme
  76  
  77  See also
  78  --------
  79  `numpy.polynomial`
  80  
  81  �N)�normalize_axis_index�)�	polyutils)�ABCPolyBase)�	hermezero�hermeone�hermex�hermedomain�	hermeline�hermeadd�hermesub�	hermemulx�hermemul�hermediv�hermepow�hermeval�hermeder�hermeint�
  82  herme2poly�
  83  poly2herme�hermefromroots�hermevander�hermefit�	hermetrim�
  84  hermeroots�HermiteE�
  85  hermeval2d�
  86  hermeval3d�hermegrid2d�hermegrid3d�
hermevander2d�
hermevander3d�hermecompanion�
  87  hermegauss�hermeweightcCsFt�|g�\}t|�d}d}t|dd�D]}tt|�||�}q|S)a�
  88      poly2herme(pol)
  89  
  90      Convert a polynomial to a Hermite series.
  91  
  92      Convert an array representing the coefficients of a polynomial (relative
  93      to the "standard" basis) ordered from lowest degree to highest, to an
  94      array of the coefficients of the equivalent Hermite series, ordered
  95      from lowest to highest degree.
  96  
  97      Parameters
  98      ----------
  99      pol : array_like
 100          1-D array containing the polynomial coefficients
 101  
 102      Returns
 103      -------
 104      c : ndarray
 105          1-D array containing the coefficients of the equivalent Hermite
 106          series.
 107  
 108      See Also
 109      --------
 110      herme2poly
 111  
 112      Notes
 113      -----
 114      The easy way to do conversions between polynomial basis sets
 115      is to use the convert method of a class instance.
 116  
 117      Examples
 118      --------
 119      >>> from numpy.polynomial.hermite_e import poly2herme
 120      >>> poly2herme(np.arange(4))
 121      array([  2.,  10.,   2.,   3.])
 122  
 123      rr�����)�pu�	as_series�len�rangerr
)�pol�deg�res�i�r.��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\numpy\polynomial\hermite_e.pyras&rc	Cs�ddlm}m}m}t�|g�\}t|�}|dkr|S|dkr!|S|d}|d}t|ddd�D]}|}|||d||d�}||||��}q1||||��S)a
 124      Convert a Hermite series to a polynomial.
 125  
 126      Convert an array representing the coefficients of a Hermite series,
 127      ordered from lowest degree to highest, to an array of the coefficients
 128      of the equivalent polynomial (relative to the "standard" basis) ordered
 129      from lowest to highest degree.
 130  
 131      Parameters
 132      ----------
 133      c : array_like
 134          1-D array containing the Hermite series coefficients, ordered
 135          from lowest order term to highest.
 136  
 137      Returns
 138      -------
 139      pol : ndarray
 140          1-D array containing the coefficients of the equivalent polynomial
 141          (relative to the "standard" basis) ordered from lowest order term
 142          to highest.
 143  
 144      See Also
 145      --------
 146      poly2herme
 147  
 148      Notes
 149      -----
 150      The easy way to do conversions between polynomial basis sets
 151      is to use the convert method of a class instance.
 152  
 153      Examples
 154      --------
 155      >>> from numpy.polynomial.hermite_e import herme2poly
 156      >>> herme2poly([  2.,  10.,   2.,   3.])
 157      array([0.,  1.,  2.,  3.])
 158  
 159      r)�polyadd�polysub�polymulx������r%)�
 160  polynomialr0r1r2r&r'r(r))	�cr0r1r2�n�c0�c1r-�tmpr.r.r/r�s&rr%cCs"|dkrt�||g�St�|g�S)a�
 161      Hermite series whose graph is a straight line.
 162  
 163      Parameters
 164      ----------
 165      off, scl : scalars
 166          The specified line is given by ``off + scl*x``.
 167  
 168      Returns
 169      -------
 170      y : ndarray
 171          This module's representation of the Hermite series for
 172          ``off + scl*x``.
 173  
 174      See Also
 175      --------
 176      numpy.polynomial.polynomial.polyline
 177      numpy.polynomial.chebyshev.chebline
 178      numpy.polynomial.legendre.legline
 179      numpy.polynomial.laguerre.lagline
 180      numpy.polynomial.hermite.hermline
 181  
 182      Examples
 183      --------
 184      >>> from numpy.polynomial.hermite_e import hermeline
 185      >>> from numpy.polynomial.hermite_e import hermeline, hermeval
 186      >>> hermeval(0,hermeline(3, 2))
 187      3.0
 188      >>> hermeval(1,hermeline(3, 2))
 189      5.0
 190  
 191      r)�np�array)�off�sclr.r.r/r
 192  �s!r
 193  cCst�tt|�S)at
 194      Generate a HermiteE series with given roots.
 195  
 196      The function returns the coefficients of the polynomial
 197  
 198      .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n),
 199  
 200      in HermiteE form, where the `r_n` are the roots specified in `roots`.
 201      If a zero has multiplicity n, then it must appear in `roots` n times.
 202      For instance, if 2 is a root of multiplicity three and 3 is a root of
 203      multiplicity 2, then `roots` looks something like [2, 2, 2, 3, 3]. The
 204      roots can appear in any order.
 205  
 206      If the returned coefficients are `c`, then
 207  
 208      .. math:: p(x) = c_0 + c_1 * He_1(x) + ... +  c_n * He_n(x)
 209  
 210      The coefficient of the last term is not generally 1 for monic
 211      polynomials in HermiteE form.
 212  
 213      Parameters
 214      ----------
 215      roots : array_like
 216          Sequence containing the roots.
 217  
 218      Returns
 219      -------
 220      out : ndarray
 221          1-D array of coefficients.  If all roots are real then `out` is a
 222          real array, if some of the roots are complex, then `out` is complex
 223          even if all the coefficients in the result are real (see Examples
 224          below).
 225  
 226      See Also
 227      --------
 228      numpy.polynomial.polynomial.polyfromroots
 229      numpy.polynomial.legendre.legfromroots
 230      numpy.polynomial.laguerre.lagfromroots
 231      numpy.polynomial.hermite.hermfromroots
 232      numpy.polynomial.chebyshev.chebfromroots
 233  
 234      Examples
 235      --------
 236      >>> from numpy.polynomial.hermite_e import hermefromroots, hermeval
 237      >>> coef = hermefromroots((-1, 0, 1))
 238      >>> hermeval((-1, 0, 1), coef)
 239      array([0., 0., 0.])
 240      >>> coef = hermefromroots((-1j, 1j))
 241      >>> hermeval((-1j, 1j), coef)
 242      array([0.+0.j, 0.+0.j])
 243  
 244      )r&�
 245  _fromrootsr
 246  r)�rootsr.r.r/rs5rcC�t�||�S)a�
 247      Add one Hermite series to another.
 248  
 249      Returns the sum of two Hermite series `c1` + `c2`.  The arguments
 250      are sequences of coefficients ordered from lowest order term to
 251      highest, i.e., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.
 252  
 253      Parameters
 254      ----------
 255      c1, c2 : array_like
 256          1-D arrays of Hermite series coefficients ordered from low to
 257          high.
 258  
 259      Returns
 260      -------
 261      out : ndarray
 262          Array representing the Hermite series of their sum.
 263  
 264      See Also
 265      --------
 266      hermesub, hermemulx, hermemul, hermediv, hermepow
 267  
 268      Notes
 269      -----
 270      Unlike multiplication, division, etc., the sum of two Hermite series
 271      is a Hermite series (without having to "reproject" the result onto
 272      the basis set) so addition, just like that of "standard" polynomials,
 273      is simply "component-wise."
 274  
 275      Examples
 276      --------
 277      >>> from numpy.polynomial.hermite_e import hermeadd
 278      >>> hermeadd([1, 2, 3], [1, 2, 3, 4])
 279      array([2.,  4.,  6.,  4.])
 280  
 281      )r&�_add�r9�c2r.r.r/r8�%rcCrA)a�
 282      Subtract one Hermite series from another.
 283  
 284      Returns the difference of two Hermite series `c1` - `c2`.  The
 285      sequences of coefficients are from lowest order term to highest, i.e.,
 286      [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.
 287  
 288      Parameters
 289      ----------
 290      c1, c2 : array_like
 291          1-D arrays of Hermite series coefficients ordered from low to
 292          high.
 293  
 294      Returns
 295      -------
 296      out : ndarray
 297          Of Hermite series coefficients representing their difference.
 298  
 299      See Also
 300      --------
 301      hermeadd, hermemulx, hermemul, hermediv, hermepow
 302  
 303      Notes
 304      -----
 305      Unlike multiplication, division, etc., the difference of two Hermite
 306      series is a Hermite series (without having to "reproject" the result
 307      onto the basis set) so subtraction, just like that of "standard"
 308      polynomials, is simply "component-wise."
 309  
 310      Examples
 311      --------
 312      >>> from numpy.polynomial.hermite_e import hermesub
 313      >>> hermesub([1, 2, 3, 4], [1, 2, 3])
 314      array([0., 0., 0., 4.])
 315  
 316      )r&�_subrCr.r.r/r`rErcCs�t�|g�\}t|�dkr|ddkr|Stjt|�d|jd�}|dd|d<|d|d<tdt|��D]}||||d<||d|||7<q6|S)a�Multiply a Hermite series by x.
 317  
 318      Multiply the Hermite series `c` by x, where x is the independent
 319      variable.
 320  
 321  
 322      Parameters
 323      ----------
 324      c : array_like
 325          1-D array of Hermite series coefficients ordered from low to
 326          high.
 327  
 328      Returns
 329      -------
 330      out : ndarray
 331          Array representing the result of the multiplication.
 332  
 333      Notes
 334      -----
 335      The multiplication uses the recursion relationship for Hermite
 336      polynomials in the form
 337  
 338      .. math::
 339  
 340          xP_i(x) = (P_{i + 1}(x) + iP_{i - 1}(x)))
 341  
 342      Examples
 343      --------
 344      >>> from numpy.polynomial.hermite_e import hermemulx
 345      >>> hermemulx([1, 2, 3])
 346      array([2.,  7.,  2.,  3.])
 347  
 348      rr��dtype)r&r'r(r;�emptyrHr))r6�prdr-r.r.r/r
�s#r
cCs�t�||g�\}}t|�t|�kr|}|}n|}|}t|�dkr)|d|}d}nJt|�dkr<|d|}|d|}n7t|�}|d|}|d|}tdt|�d�D]}|}|d}t|||||d�}t|t|��}qUt|t|��S)aZ
 349      Multiply one Hermite series by another.
 350  
 351      Returns the product of two Hermite series `c1` * `c2`.  The arguments
 352      are sequences of coefficients, from lowest order "term" to highest,
 353      e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.
 354  
 355      Parameters
 356      ----------
 357      c1, c2 : array_like
 358          1-D arrays of Hermite series coefficients ordered from low to
 359          high.
 360  
 361      Returns
 362      -------
 363      out : ndarray
 364          Of Hermite series coefficients representing their product.
 365  
 366      See Also
 367      --------
 368      hermeadd, hermesub, hermemulx, hermediv, hermepow
 369  
 370      Notes
 371      -----
 372      In general, the (polynomial) product of two C-series results in terms
 373      that are not in the Hermite polynomial basis set.  Thus, to express
 374      the product as a Hermite series, it is necessary to "reproject" the
 375      product onto said basis set, which may produce "unintuitive" (but
 376      correct) results; see Examples section below.
 377  
 378      Examples
 379      --------
 380      >>> from numpy.polynomial.hermite_e import hermemul
 381      >>> hermemul([1, 2, 3], [0, 1, 2])
 382      array([14.,  15.,  28.,   7.,   6.])
 383  
 384      rrr3r4r%�)r&r'r(r)rrr
)r9rDr6�xsr8�ndr-r:r.r.r/r�s*'rcCst�t||�S)a8
 385      Divide one Hermite series by another.
 386  
 387      Returns the quotient-with-remainder of two Hermite series
 388      `c1` / `c2`.  The arguments are sequences of coefficients from lowest
 389      order "term" to highest, e.g., [1,2,3] represents the series
 390      ``P_0 + 2*P_1 + 3*P_2``.
 391  
 392      Parameters
 393      ----------
 394      c1, c2 : array_like
 395          1-D arrays of Hermite series coefficients ordered from low to
 396          high.
 397  
 398      Returns
 399      -------
 400      [quo, rem] : ndarrays
 401          Of Hermite series coefficients representing the quotient and
 402          remainder.
 403  
 404      See Also
 405      --------
 406      hermeadd, hermesub, hermemulx, hermemul, hermepow
 407  
 408      Notes
 409      -----
 410      In general, the (polynomial) division of one Hermite series by another
 411      results in quotient and remainder terms that are not in the Hermite
 412      polynomial basis set.  Thus, to express these results as a Hermite
 413      series, it is necessary to "reproject" the results onto the Hermite
 414      basis set, which may produce "unintuitive" (but correct) results; see
 415      Examples section below.
 416  
 417      Examples
 418      --------
 419      >>> from numpy.polynomial.hermite_e import hermediv
 420      >>> hermediv([ 14.,  15.,  28.,   7.,   6.], [0, 1, 2])
 421      (array([1., 2., 3.]), array([0.]))
 422      >>> hermediv([ 15.,  17.,  28.,   7.,   6.], [0, 1, 2])
 423      (array([1., 2., 3.]), array([1., 2.]))
 424  
 425      )r&�_divrrCr.r.r/r�s+r�cCst�t|||�S)a�Raise a Hermite series to a power.
 426  
 427      Returns the Hermite series `c` raised to the power `pow`. The
 428      argument `c` is a sequence of coefficients ordered from low to high.
 429      i.e., [1,2,3] is the series  ``P_0 + 2*P_1 + 3*P_2.``
 430  
 431      Parameters
 432      ----------
 433      c : array_like
 434          1-D array of Hermite series coefficients ordered from low to
 435          high.
 436      pow : integer
 437          Power to which the series will be raised
 438      maxpower : integer, optional
 439          Maximum power allowed. This is mainly to limit growth of the series
 440          to unmanageable size. Default is 16
 441  
 442      Returns
 443      -------
 444      coef : ndarray
 445          Hermite series of power.
 446  
 447      See Also
 448      --------
 449      hermeadd, hermesub, hermemulx, hermemul, hermediv
 450  
 451      Examples
 452      --------
 453      >>> from numpy.polynomial.hermite_e import hermepow
 454      >>> hermepow([1, 2, 3], 2)
 455      array([23.,  28.,  46.,  12.,   9.])
 456  
 457      )r&�_powr)r6�pow�maxpowerr.r.r/r)s"rc
 458  Cstj|ddd�}|jjdvr|�tj�}t�|d�}t�|d�}|dkr(td��t	||j
 459  �}|dkr4|St�||d�}t|�}||krK|d	d�dSt
|�D]/}|d}||9}tj|f|jdd	�|jd
 460  �}t
|dd�D]}	|	||	||	d<qo|}qOt�|d|�}|S)aF
 461      Differentiate a Hermite_e series.
 462  
 463      Returns the series coefficients `c` differentiated `m` times along
 464      `axis`.  At each iteration the result is multiplied by `scl` (the
 465      scaling factor is for use in a linear change of variable). The argument
 466      `c` is an array of coefficients from low to high degree along each
 467      axis, e.g., [1,2,3] represents the series ``1*He_0 + 2*He_1 + 3*He_2``
 468      while [[1,2],[1,2]] represents ``1*He_0(x)*He_0(y) + 1*He_1(x)*He_0(y)
 469      + 2*He_0(x)*He_1(y) + 2*He_1(x)*He_1(y)`` if axis=0 is ``x`` and axis=1
 470      is ``y``.
 471  
 472      Parameters
 473      ----------
 474      c : array_like
 475          Array of Hermite_e series coefficients. If `c` is multidimensional
 476          the different axis correspond to different variables with the
 477          degree in each axis given by the corresponding index.
 478      m : int, optional
 479          Number of derivatives taken, must be non-negative. (Default: 1)
 480      scl : scalar, optional
 481          Each differentiation is multiplied by `scl`.  The end result is
 482          multiplication by ``scl**m``.  This is for use in a linear change of
 483          variable. (Default: 1)
 484      axis : int, optional
 485          Axis over which the derivative is taken. (Default: 0).
 486  
 487          .. versionadded:: 1.7.0
 488  
 489      Returns
 490      -------
 491      der : ndarray
 492          Hermite series of the derivative.
 493  
 494      See Also
 495      --------
 496      hermeint
 497  
 498      Notes
 499      -----
 500      In general, the result of differentiating a Hermite series does not
 501      resemble the same operation on a power series. Thus the result of this
 502      function may be "unintuitive," albeit correct; see Examples section
 503      below.
 504  
 505      Examples
 506      --------
 507      >>> from numpy.polynomial.hermite_e import hermeder
 508      >>> hermeder([ 1.,  1.,  1.,  1.])
 509      array([1.,  2.,  3.])
 510      >>> hermeder([-0.25,  1.,  1./2.,  1./3.,  1./4 ], m=2)
 511      array([1.,  2.,  3.])
 512  
 513      rT��ndmin�copy�
?bBhHiIlLqQpPzthe order of derivation�the axisrz,The order of derivation must be non-negativeNrGr%)r;r<rH�char�astype�doubler&�_deprecate_as_int�
 514  ValueErrorr�ndim�moveaxisr(r)rI�shape)
 515  r6�mr>�axis�cnt�iaxisr7r-�der�jr.r.r/rNs.7 rcCs�tj|ddd�}|jjdvr|�tj�}t�|�s|g}t�|d�}t�|d�}|dkr0t	d��t
 516  |�|kr:t	d	��t�|�dkrEt	d
 517  ��t�|�dkrPt	d��t||j�}|dkr\|St�
||d�}t|�dg|t
 518  |�}t|�D]g}t
 519  |�}	||9}|	dkr�t�|ddk�r�|d||7<qttj|	df|jdd�|jd
�}
 520  |dd|
 521  d<|d|
 522  d<td|	�D]}|||d|
 523  |d<q�|
 524  d||t||
 525  �7<|
 526  }qtt�
|d|�}|S)ap

 527      Integrate a Hermite_e series.
 528  
 529      Returns the Hermite_e series coefficients `c` integrated `m` times from
 530      `lbnd` along `axis`. At each iteration the resulting series is
 531      **multiplied** by `scl` and an integration constant, `k`, is added.
 532      The scaling factor is for use in a linear change of variable.  ("Buyer
 533      beware": note that, depending on what one is doing, one may want `scl`
 534      to be the reciprocal of what one might expect; for more information,
 535      see the Notes section below.)  The argument `c` is an array of
 536      coefficients from low to high degree along each axis, e.g., [1,2,3]
 537      represents the series ``H_0 + 2*H_1 + 3*H_2`` while [[1,2],[1,2]]
 538      represents ``1*H_0(x)*H_0(y) + 1*H_1(x)*H_0(y) + 2*H_0(x)*H_1(y) +
 539      2*H_1(x)*H_1(y)`` if axis=0 is ``x`` and axis=1 is ``y``.
 540  
 541      Parameters
 542      ----------
 543      c : array_like
 544          Array of Hermite_e series coefficients. If c is multidimensional
 545          the different axis correspond to different variables with the
 546          degree in each axis given by the corresponding index.
 547      m : int, optional
 548          Order of integration, must be positive. (Default: 1)
 549      k : {[], list, scalar}, optional
 550          Integration constant(s).  The value of the first integral at
 551          ``lbnd`` is the first value in the list, the value of the second
 552          integral at ``lbnd`` is the second value, etc.  If ``k == []`` (the
 553          default), all constants are set to zero.  If ``m == 1``, a single
 554          scalar can be given instead of a list.
 555      lbnd : scalar, optional
 556          The lower bound of the integral. (Default: 0)
 557      scl : scalar, optional
 558          Following each integration the result is *multiplied* by `scl`
 559          before the integration constant is added. (Default: 1)
 560      axis : int, optional
 561          Axis over which the integral is taken. (Default: 0).
 562  
 563          .. versionadded:: 1.7.0
 564  
 565      Returns
 566      -------
 567      S : ndarray
 568          Hermite_e series coefficients of the integral.
 569  
 570      Raises
 571      ------
 572      ValueError
 573          If ``m < 0``, ``len(k) > m``, ``np.ndim(lbnd) != 0``, or
 574          ``np.ndim(scl) != 0``.
 575  
 576      See Also
 577      --------
 578      hermeder
 579  
 580      Notes
 581      -----
 582      Note that the result of each integration is *multiplied* by `scl`.
 583      Why is this important to note?  Say one is making a linear change of
 584      variable :math:`u = ax + b` in an integral relative to `x`.  Then
 585      :math:`dx = du/a`, so one will need to set `scl` equal to
 586      :math:`1/a` - perhaps not what one would have first thought.
 587  
 588      Also note that, in general, the result of integrating a C-series needs
 589      to be "reprojected" onto the C-series basis set.  Thus, typically,
 590      the result of this function is "unintuitive," albeit correct; see
 591      Examples section below.
 592  
 593      Examples
 594      --------
 595      >>> from numpy.polynomial.hermite_e import hermeint
 596      >>> hermeint([1, 2, 3]) # integrate once, value 0 at 0.
 597      array([1., 1., 1., 1.])
 598      >>> hermeint([1, 2, 3], m=2) # integrate twice, value & deriv 0 at 0
 599      array([-0.25      ,  1.        ,  0.5       ,  0.33333333,  0.25      ]) # may vary
 600      >>> hermeint([1, 2, 3], k=1) # integrate once, value 1 at 0.
 601      array([2., 1., 1., 1.])
 602      >>> hermeint([1, 2, 3], lbnd=-1) # integrate once, value 0 at -1
 603      array([-1.,  1.,  1.,  1.])
 604      >>> hermeint([1, 2, 3], m=2, k=[1, 2], lbnd=-1)
 605      array([ 1.83333333,  0.        ,  0.5       ,  0.33333333,  0.25      ]) # may vary
 606  
 607      rTrSrVzthe order of integrationrWrz-The order of integration must be non-negativezToo many integration constantszlbnd must be a scalar.zscl must be a scalar.NrG)r;r<rHrXrYrZ�iterabler&r[r\r(r]rr^�listr)�allrIr_r)r6r`�k�lbndr>rarbrcr-r7r:rer.r.r/r�sDS
 608  $rTcCstj|ddd�}|jjdvr|�tj�}t|ttf�r t�	|�}t|tj
 609  �r3|r3|�|jd|j
�}t|�dkr@|d}d}n>t|�dkrO|d}|d}n/t|�}|d}|d	}td
 610  t|�d�D]}|}|d}||||d}|||}qd|||S)a9
 611  
 612      Evaluate an HermiteE series at points x.
 613  
 614      If `c` is of length `n + 1`, this function returns the value:
 615  
 616      .. math:: p(x) = c_0 * He_0(x) + c_1 * He_1(x) + ... + c_n * He_n(x)
 617  
 618      The parameter `x` is converted to an array only if it is a tuple or a
 619      list, otherwise it is treated as a scalar. In either case, either `x`
 620      or its elements must support multiplication and addition both with
 621      themselves and with the elements of `c`.
 622  
 623      If `c` is a 1-D array, then `p(x)` will have the same shape as `x`.  If
 624      `c` is multidimensional, then the shape of the result depends on the
 625      value of `tensor`. If `tensor` is true the shape will be c.shape[1:] +
 626      x.shape. If `tensor` is false the shape will be c.shape[1:]. Note that
 627      scalars have shape (,).
 628  
 629      Trailing zeros in the coefficients will be used in the evaluation, so
 630      they should be avoided if efficiency is a concern.
 631  
 632      Parameters
 633      ----------
 634      x : array_like, compatible object
 635          If `x` is a list or tuple, it is converted to an ndarray, otherwise
 636          it is left unchanged and treated as a scalar. In either case, `x`
 637          or its elements must support addition and multiplication with
 638          with themselves and with the elements of `c`.
 639      c : array_like
 640          Array of coefficients ordered so that the coefficients for terms of
 641          degree n are contained in c[n]. If `c` is multidimensional the
 642          remaining indices enumerate multiple polynomials. In the two
 643          dimensional case the coefficients may be thought of as stored in
 644          the columns of `c`.
 645      tensor : boolean, optional
 646          If True, the shape of the coefficient array is extended with ones
 647          on the right, one for each dimension of `x`. Scalars have dimension 0
 648          for this action. The result is that every column of coefficients in
 649          `c` is evaluated for every element of `x`. If False, `x` is broadcast
 650          over the columns of `c` for the evaluation.  This keyword is useful
 651          when `c` is multidimensional. The default value is True.
 652  
 653          .. versionadded:: 1.7.0
 654  
 655      Returns
 656      -------
 657      values : ndarray, algebra_like
 658          The shape of the return value is described above.
 659  
 660      See Also
 661      --------
 662      hermeval2d, hermegrid2d, hermeval3d, hermegrid3d
 663  
 664      Notes
 665      -----
 666      The evaluation uses Clenshaw recursion, aka synthetic division.
 667  
 668      Examples
 669      --------
 670      >>> from numpy.polynomial.hermite_e import hermeval
 671      >>> coef = [1,2,3]
 672      >>> hermeval(1, coef)
 673      3.0
 674      >>> hermeval([[1,2],[3,4]], coef)
 675      array([[ 3., 14.],
 676             [31., 54.]])
 677  
 678      rFrSrV)rrr3r4r%rK)r;r<rHrXrYrZ�
 679  isinstance�tuplerg�asarray�ndarray�reshaper_r]r(r))�xr6�tensorr8r9rMr-r:r.r.r/rs,E
 680  
 681  rcC�t�t|||�S)aI
 682      Evaluate a 2-D HermiteE series at points (x, y).
 683  
 684      This function returns the values:
 685  
 686      .. math:: p(x,y) = \sum_{i,j} c_{i,j} * He_i(x) * He_j(y)
 687  
 688      The parameters `x` and `y` are converted to arrays only if they are
 689      tuples or a lists, otherwise they are treated as a scalars and they
 690      must have the same shape after conversion. In either case, either `x`
 691      and `y` or their elements must support multiplication and addition both
 692      with themselves and with the elements of `c`.
 693  
 694      If `c` is a 1-D array a one is implicitly appended to its shape to make
 695      it 2-D. The shape of the result will be c.shape[2:] + x.shape.
 696  
 697      Parameters
 698      ----------
 699      x, y : array_like, compatible objects
 700          The two dimensional series is evaluated at the points `(x, y)`,
 701          where `x` and `y` must have the same shape. If `x` or `y` is a list
 702          or tuple, it is first converted to an ndarray, otherwise it is left
 703          unchanged and if it isn't an ndarray it is treated as a scalar.
 704      c : array_like
 705          Array of coefficients ordered so that the coefficient of the term
 706          of multi-degree i,j is contained in ``c[i,j]``. If `c` has
 707          dimension greater than two the remaining indices enumerate multiple
 708          sets of coefficients.
 709  
 710      Returns
 711      -------
 712      values : ndarray, compatible object
 713          The values of the two dimensional polynomial at points formed with
 714          pairs of corresponding values from `x` and `y`.
 715  
 716      See Also
 717      --------
 718      hermeval, hermegrid2d, hermeval3d, hermegrid3d
 719  
 720      Notes
 721      -----
 722  
 723      .. versionadded:: 1.7.0
 724  
 725      �r&�_valndr�rp�yr6r.r.r/rzs.rcCrr)a�
 726      Evaluate a 2-D HermiteE series on the Cartesian product of x and y.
 727  
 728      This function returns the values:
 729  
 730      .. math:: p(a,b) = \sum_{i,j} c_{i,j} * H_i(a) * H_j(b)
 731  
 732      where the points `(a, b)` consist of all pairs formed by taking
 733      `a` from `x` and `b` from `y`. The resulting points form a grid with
 734      `x` in the first dimension and `y` in the second.
 735  
 736      The parameters `x` and `y` are converted to arrays only if they are
 737      tuples or a lists, otherwise they are treated as a scalars. In either
 738      case, either `x` and `y` or their elements must support multiplication
 739      and addition both with themselves and with the elements of `c`.
 740  
 741      If `c` has fewer than two dimensions, ones are implicitly appended to
 742      its shape to make it 2-D. The shape of the result will be c.shape[2:] +
 743      x.shape.
 744  
 745      Parameters
 746      ----------
 747      x, y : array_like, compatible objects
 748          The two dimensional series is evaluated at the points in the
 749          Cartesian product of `x` and `y`.  If `x` or `y` is a list or
 750          tuple, it is first converted to an ndarray, otherwise it is left
 751          unchanged and, if it isn't an ndarray, it is treated as a scalar.
 752      c : array_like
 753          Array of coefficients ordered so that the coefficients for terms of
 754          degree i,j are contained in ``c[i,j]``. If `c` has dimension
 755          greater than two the remaining indices enumerate multiple sets of
 756          coefficients.
 757  
 758      Returns
 759      -------
 760      values : ndarray, compatible object
 761          The values of the two dimensional polynomial at points in the Cartesian
 762          product of `x` and `y`.
 763  
 764      See Also
 765      --------
 766      hermeval, hermeval2d, hermeval3d, hermegrid3d
 767  
 768      Notes
 769      -----
 770  
 771      .. versionadded:: 1.7.0
 772  
 773      �r&�_gridndrrur.r.r/r�s2rcC�t�t||||�S)a�
 774      Evaluate a 3-D Hermite_e series at points (x, y, z).
 775  
 776      This function returns the values:
 777  
 778      .. math:: p(x,y,z) = \sum_{i,j,k} c_{i,j,k} * He_i(x) * He_j(y) * He_k(z)
 779  
 780      The parameters `x`, `y`, and `z` are converted to arrays only if
 781      they are tuples or a lists, otherwise they are treated as a scalars and
 782      they must have the same shape after conversion. In either case, either
 783      `x`, `y`, and `z` or their elements must support multiplication and
 784      addition both with themselves and with the elements of `c`.
 785  
 786      If `c` has fewer than 3 dimensions, ones are implicitly appended to its
 787      shape to make it 3-D. The shape of the result will be c.shape[3:] +
 788      x.shape.
 789  
 790      Parameters
 791      ----------
 792      x, y, z : array_like, compatible object
 793          The three dimensional series is evaluated at the points
 794          `(x, y, z)`, where `x`, `y`, and `z` must have the same shape.  If
 795          any of `x`, `y`, or `z` is a list or tuple, it is first converted
 796          to an ndarray, otherwise it is left unchanged and if it isn't an
 797          ndarray it is  treated as a scalar.
 798      c : array_like
 799          Array of coefficients ordered so that the coefficient of the term of
 800          multi-degree i,j,k is contained in ``c[i,j,k]``. If `c` has dimension
 801          greater than 3 the remaining indices enumerate multiple sets of
 802          coefficients.
 803  
 804      Returns
 805      -------
 806      values : ndarray, compatible object
 807          The values of the multidimensional polynomial on points formed with
 808          triples of corresponding values from `x`, `y`, and `z`.
 809  
 810      See Also
 811      --------
 812      hermeval, hermeval2d, hermegrid2d, hermegrid3d
 813  
 814      Notes
 815      -----
 816  
 817      .. versionadded:: 1.7.0
 818  
 819      rs�rprv�zr6r.r.r/r�s0rcCry)aV
 820      Evaluate a 3-D HermiteE series on the Cartesian product of x, y, and z.
 821  
 822      This function returns the values:
 823  
 824      .. math:: p(a,b,c) = \sum_{i,j,k} c_{i,j,k} * He_i(a) * He_j(b) * He_k(c)
 825  
 826      where the points `(a, b, c)` consist of all triples formed by taking
 827      `a` from `x`, `b` from `y`, and `c` from `z`. The resulting points form
 828      a grid with `x` in the first dimension, `y` in the second, and `z` in
 829      the third.
 830  
 831      The parameters `x`, `y`, and `z` are converted to arrays only if they
 832      are tuples or a lists, otherwise they are treated as a scalars. In
 833      either case, either `x`, `y`, and `z` or their elements must support
 834      multiplication and addition both with themselves and with the elements
 835      of `c`.
 836  
 837      If `c` has fewer than three dimensions, ones are implicitly appended to
 838      its shape to make it 3-D. The shape of the result will be c.shape[3:] +
 839      x.shape + y.shape + z.shape.
 840  
 841      Parameters
 842      ----------
 843      x, y, z : array_like, compatible objects
 844          The three dimensional series is evaluated at the points in the
 845          Cartesian product of `x`, `y`, and `z`.  If `x`,`y`, or `z` is a
 846          list or tuple, it is first converted to an ndarray, otherwise it is
 847          left unchanged and, if it isn't an ndarray, it is treated as a
 848          scalar.
 849      c : array_like
 850          Array of coefficients ordered so that the coefficients for terms of
 851          degree i,j are contained in ``c[i,j]``. If `c` has dimension
 852          greater than two the remaining indices enumerate multiple sets of
 853          coefficients.
 854  
 855      Returns
 856      -------
 857      values : ndarray, compatible object
 858          The values of the two dimensional polynomial at points in the Cartesian
 859          product of `x` and `y`.
 860  
 861      See Also
 862      --------
 863      hermeval, hermeval2d, hermegrid2d, hermeval3d
 864  
 865      Notes
 866      -----
 867  
 868      .. versionadded:: 1.7.0
 869  
 870      rwrzr.r.r/rs5rcCs�t�|d�}|dkrtd��tj|ddd�d}|df|j}|j}tj||d�}|dd|d<|dkrX||d<td	|d�D]}||d|||d	|d||<qAt�	|dd
 871  �S)aPseudo-Vandermonde matrix of given degree.
 872  
 873      Returns the pseudo-Vandermonde matrix of degree `deg` and sample points
 874      `x`. The pseudo-Vandermonde matrix is defined by
 875  
 876      .. math:: V[..., i] = He_i(x),
 877  
 878      where `0 <= i <= deg`. The leading indices of `V` index the elements of
 879      `x` and the last index is the degree of the HermiteE polynomial.
 880  
 881      If `c` is a 1-D array of coefficients of length `n + 1` and `V` is the
 882      array ``V = hermevander(x, n)``, then ``np.dot(V, c)`` and
 883      ``hermeval(x, c)`` are the same up to roundoff. This equivalence is
 884      useful both for least squares fitting and for the evaluation of a large
 885      number of HermiteE series of the same degree and sample points.
 886  
 887      Parameters
 888      ----------
 889      x : array_like
 890          Array of points. The dtype is converted to float64 or complex128
 891          depending on whether any of the elements are complex. If `x` is
 892          scalar it is converted to a 1-D array.
 893      deg : int
 894          Degree of the resulting matrix.
 895  
 896      Returns
 897      -------
 898      vander : ndarray
 899          The pseudo-Vandermonde matrix. The shape of the returned matrix is
 900          ``x.shape + (deg + 1,)``, where The last index is the degree of the
 901          corresponding HermiteE polynomial.  The dtype will be the same as
 902          the converted `x`.
 903  
 904      Examples
 905      --------
 906      >>> from numpy.polynomial.hermite_e import hermevander
 907      >>> x = np.array([-1, 0, 1])
 908      >>> hermevander(x, 3)
 909      array([[ 1., -1.,  0.,  2.],
 910             [ 1.,  0., -1., -0.],
 911             [ 1.,  1.,  0., -2.]])
 912  
 913      r+rzdeg must be non-negativeFr)rUrT�rGr3r%)
 914  r&r[r\r;r<r_rHrIr)r^)rpr+�ideg�dims�dtyp�vr-r.r.r/rKs,*rcCst�ttf||f|�S)a�Pseudo-Vandermonde matrix of given degrees.
 915  
 916      Returns the pseudo-Vandermonde matrix of degrees `deg` and sample
 917      points `(x, y)`. The pseudo-Vandermonde matrix is defined by
 918  
 919      .. math:: V[..., (deg[1] + 1)*i + j] = He_i(x) * He_j(y),
 920  
 921      where `0 <= i <= deg[0]` and `0 <= j <= deg[1]`. The leading indices of
 922      `V` index the points `(x, y)` and the last index encodes the degrees of
 923      the HermiteE polynomials.
 924  
 925      If ``V = hermevander2d(x, y, [xdeg, ydeg])``, then the columns of `V`
 926      correspond to the elements of a 2-D coefficient array `c` of shape
 927      (xdeg + 1, ydeg + 1) in the order
 928  
 929      .. math:: c_{00}, c_{01}, c_{02} ... , c_{10}, c_{11}, c_{12} ...
 930  
 931      and ``np.dot(V, c.flat)`` and ``hermeval2d(x, y, c)`` will be the same
 932      up to roundoff. This equivalence is useful both for least squares
 933      fitting and for the evaluation of a large number of 2-D HermiteE
 934      series of the same degrees and sample points.
 935  
 936      Parameters
 937      ----------
 938      x, y : array_like
 939          Arrays of point coordinates, all of the same shape. The dtypes
 940          will be converted to either float64 or complex128 depending on
 941          whether any of the elements are complex. Scalars are converted to
 942          1-D arrays.
 943      deg : list of ints
 944          List of maximum degrees of the form [x_deg, y_deg].
 945  
 946      Returns
 947      -------
 948      vander2d : ndarray
 949          The shape of the returned matrix is ``x.shape + (order,)``, where
 950          :math:`order = (deg[0]+1)*(deg[1]+1)`.  The dtype will be the same
 951          as the converted `x` and `y`.
 952  
 953      See Also
 954      --------
 955      hermevander, hermevander3d, hermeval2d, hermeval3d
 956  
 957      Notes
 958      -----
 959  
 960      .. versionadded:: 1.7.0
 961  
 962      �r&�_vander_nd_flatr)rprvr+r.r.r/r �s2r cCst�tttf|||f|�S)a&Pseudo-Vandermonde matrix of given degrees.
 963  
 964      Returns the pseudo-Vandermonde matrix of degrees `deg` and sample
 965      points `(x, y, z)`. If `l, m, n` are the given degrees in `x, y, z`,
 966      then Hehe pseudo-Vandermonde matrix is defined by
 967  
 968      .. math:: V[..., (m+1)(n+1)i + (n+1)j + k] = He_i(x)*He_j(y)*He_k(z),
 969  
 970      where `0 <= i <= l`, `0 <= j <= m`, and `0 <= j <= n`.  The leading
 971      indices of `V` index the points `(x, y, z)` and the last index encodes
 972      the degrees of the HermiteE polynomials.
 973  
 974      If ``V = hermevander3d(x, y, z, [xdeg, ydeg, zdeg])``, then the columns
 975      of `V` correspond to the elements of a 3-D coefficient array `c` of
 976      shape (xdeg + 1, ydeg + 1, zdeg + 1) in the order
 977  
 978      .. math:: c_{000}, c_{001}, c_{002},... , c_{010}, c_{011}, c_{012},...
 979  
 980      and  ``np.dot(V, c.flat)`` and ``hermeval3d(x, y, z, c)`` will be the
 981      same up to roundoff. This equivalence is useful both for least squares
 982      fitting and for the evaluation of a large number of 3-D HermiteE
 983      series of the same degrees and sample points.
 984  
 985      Parameters
 986      ----------
 987      x, y, z : array_like
 988          Arrays of point coordinates, all of the same shape. The dtypes will
 989          be converted to either float64 or complex128 depending on whether
 990          any of the elements are complex. Scalars are converted to 1-D
 991          arrays.
 992      deg : list of ints
 993          List of maximum degrees of the form [x_deg, y_deg, z_deg].
 994  
 995      Returns
 996      -------
 997      vander3d : ndarray
 998          The shape of the returned matrix is ``x.shape + (order,)``, where
 999          :math:`order = (deg[0]+1)*(deg[1]+1)*(deg[2]+1)`.  The dtype will
1000          be the same as the converted `x`, `y`, and `z`.
1001  
1002      See Also
1003      --------
1004      hermevander, hermevander3d, hermeval2d, hermeval3d
1005  
1006      Notes
1007      -----
1008  
1009      .. versionadded:: 1.7.0
1010  
1011      r�)rprvr{r+r.r.r/r!�s3r!Fc	Cst�t||||||�S)ag
1012      Least squares fit of Hermite series to data.
1013  
1014      Return the coefficients of a HermiteE series of degree `deg` that is
1015      the least squares fit to the data values `y` given at points `x`. If
1016      `y` is 1-D the returned coefficients will also be 1-D. If `y` is 2-D
1017      multiple fits are done, one for each column of `y`, and the resulting
1018      coefficients are stored in the corresponding columns of a 2-D return.
1019      The fitted polynomial(s) are in the form
1020  
1021      .. math::  p(x) = c_0 + c_1 * He_1(x) + ... + c_n * He_n(x),
1022  
1023      where `n` is `deg`.
1024  
1025      Parameters
1026      ----------
1027      x : array_like, shape (M,)
1028          x-coordinates of the M sample points ``(x[i], y[i])``.
1029      y : array_like, shape (M,) or (M, K)
1030          y-coordinates of the sample points. Several data sets of sample
1031          points sharing the same x-coordinates can be fitted at once by
1032          passing in a 2D-array that contains one dataset per column.
1033      deg : int or 1-D array_like
1034          Degree(s) of the fitting polynomials. If `deg` is a single integer
1035          all terms up to and including the `deg`'th term are included in the
1036          fit. For NumPy versions >= 1.11.0 a list of integers specifying the
1037          degrees of the terms to include may be used instead.
1038      rcond : float, optional
1039          Relative condition number of the fit. Singular values smaller than
1040          this relative to the largest singular value will be ignored. The
1041          default value is len(x)*eps, where eps is the relative precision of
1042          the float type, about 2e-16 in most cases.
1043      full : bool, optional
1044          Switch determining nature of return value. When it is False (the
1045          default) just the coefficients are returned, when True diagnostic
1046          information from the singular value decomposition is also returned.
1047      w : array_like, shape (`M`,), optional
1048          Weights. If not None, the weight ``w[i]`` applies to the unsquared
1049          residual ``y[i] - y_hat[i]`` at ``x[i]``. Ideally the weights are
1050          chosen so that the errors of the products ``w[i]*y[i]`` all have the
1051          same variance.  When using inverse-variance weighting, use
1052          ``w[i] = 1/sigma(y[i])``.  The default value is None.
1053  
1054      Returns
1055      -------
1056      coef : ndarray, shape (M,) or (M, K)
1057          Hermite coefficients ordered from low to high. If `y` was 2-D,
1058          the coefficients for the data in column k  of `y` are in column
1059          `k`.
1060  
1061      [residuals, rank, singular_values, rcond] : list
1062          These values are only returned if ``full == True``
1063  
1064          - residuals -- sum of squared residuals of the least squares fit
1065          - rank -- the numerical rank of the scaled Vandermonde matrix
1066          - singular_values -- singular values of the scaled Vandermonde matrix
1067          - rcond -- value of `rcond`.
1068  
1069          For more details, see `numpy.linalg.lstsq`.
1070  
1071      Warns
1072      -----
1073      RankWarning
1074          The rank of the coefficient matrix in the least-squares fit is
1075          deficient. The warning is only raised if ``full = False``.  The
1076          warnings can be turned off by
1077  
1078          >>> import warnings
1079          >>> warnings.simplefilter('ignore', np.RankWarning)
1080  
1081      See Also
1082      --------
1083      numpy.polynomial.chebyshev.chebfit
1084      numpy.polynomial.legendre.legfit
1085      numpy.polynomial.polynomial.polyfit
1086      numpy.polynomial.hermite.hermfit
1087      numpy.polynomial.laguerre.lagfit
1088      hermeval : Evaluates a Hermite series.
1089      hermevander : pseudo Vandermonde matrix of Hermite series.
1090      hermeweight : HermiteE weight function.
1091      numpy.linalg.lstsq : Computes a least-squares fit from the matrix.
1092      scipy.interpolate.UnivariateSpline : Computes spline fits.
1093  
1094      Notes
1095      -----
1096      The solution is the coefficients of the HermiteE series `p` that
1097      minimizes the sum of the weighted squared errors
1098  
1099      .. math:: E = \sum_j w_j^2 * |y_j - p(x_j)|^2,
1100  
1101      where the :math:`w_j` are the weights. This problem is solved by
1102      setting up the (typically) overdetermined matrix equation
1103  
1104      .. math:: V(x) * c = w * y,
1105  
1106      where `V` is the pseudo Vandermonde matrix of `x`, the elements of `c`
1107      are the coefficients to be solved for, and the elements of `y` are the
1108      observed values.  This equation is then solved using the singular value
1109      decomposition of `V`.
1110  
1111      If some of the singular values of `V` are so small that they are
1112      neglected, then a `RankWarning` will be issued. This means that the
1113      coefficient values may be poorly determined. Using a lower order fit
1114      will usually get rid of the warning.  The `rcond` parameter can also be
1115      set to a value smaller than its default, but the resulting fit may be
1116      spurious and have large contributions from roundoff error.
1117  
1118      Fits using HermiteE series are probably most useful when the data can
1119      be approximated by ``sqrt(w(x)) * p(x)``, where `w(x)` is the HermiteE
1120      weight. In that case the weight ``sqrt(w(x[i]))`` should be used
1121      together with data values ``y[i]/sqrt(w(x[i]))``. The weight function is
1122      available as `hermeweight`.
1123  
1124      References
1125      ----------
1126      .. [1] Wikipedia, "Curve fitting",
1127             https://en.wikipedia.org/wiki/Curve_fitting
1128  
1129      Examples
1130      --------
1131      >>> from numpy.polynomial.hermite_e import hermefit, hermeval
1132      >>> x = np.linspace(-10, 10)
1133      >>> np.random.seed(123)
1134      >>> err = np.random.randn(len(x))/10
1135      >>> y = hermeval(x, [1, 2, 3]) + err
1136      >>> hermefit(x, y, 2)
1137      array([ 1.01690445,  1.99951418,  2.99948696]) # may vary
1138  
1139      )r&�_fitr)rprvr+�rcond�full�wr.r.r/r�srcCs$t�|g�\}t|�dkrtd��t|�dkr%t�|d|dgg�St|�d}tj||f|jd�}t�ddt�	t�
1140  |ddd��f�}tj�|�ddd�}|�
d�dd|d�}|�
d�|d|d�}t�	t�
1141  d|��|d	<||d	<|dd�df||dd�|d8<|S)
1142  a�
1143      Return the scaled companion matrix of c.
1144  
1145      The basis polynomials are scaled so that the companion matrix is
1146      symmetric when `c` is an HermiteE basis polynomial. This provides
1147      better eigenvalue estimates than the unscaled case and for basis
1148      polynomials the eigenvalues are guaranteed to be real if
1149      `numpy.linalg.eigvalsh` is used to obtain them.
1150  
1151      Parameters
1152      ----------
1153      c : array_like
1154          1-D array of HermiteE series coefficients ordered from low to high
1155          degree.
1156  
1157      Returns
1158      -------
1159      mat : ndarray
1160          Scaled companion matrix of dimensions (deg, deg).
1161  
1162      Notes
1163      -----
1164  
1165      .. versionadded:: 1.7.0
1166  
1167      r3z.Series must have maximum degree of at least 1.rrrG��?r%N.)r&r'r(r\r;r<�zerosrH�hstack�sqrt�arange�multiply�
1168  accumulatero)r6r7�matr>�top�botr.r.r/r"ws&,r"cCs�t�|g�\}t|�dkrtjg|jd�St|�dkr(t�|d|dg�St|�ddd�ddd�f}t�|�}|�	�|S)a�
1169      Compute the roots of a HermiteE series.
1170  
1171      Return the roots (a.k.a. "zeros") of the polynomial
1172  
1173      .. math:: p(x) = \sum_i c[i] * He_i(x).
1174  
1175      Parameters
1176      ----------
1177      c : 1-D array_like
1178          1-D array of coefficients.
1179  
1180      Returns
1181      -------
1182      out : ndarray
1183          Array of the roots of the series. If all the roots are real,
1184          then `out` is also real, otherwise it is complex.
1185  
1186      See Also
1187      --------
1188      numpy.polynomial.polynomial.polyroots
1189      numpy.polynomial.legendre.legroots
1190      numpy.polynomial.laguerre.lagroots
1191      numpy.polynomial.hermite.hermroots
1192      numpy.polynomial.chebyshev.chebroots
1193  
1194      Notes
1195      -----
1196      The root estimates are obtained as the eigenvalues of the companion
1197      matrix, Roots far from the origin of the complex plane may have large
1198      errors due to the numerical instability of the series for such
1199      values. Roots with multiplicity greater than 1 will also show larger
1200      errors as the value of the series near such points is relatively
1201      insensitive to errors in the roots. Isolated roots near the origin can
1202      be improved by a few iterations of Newton's method.
1203  
1204      The HermiteE series basis polynomials aren't powers of `x` so the
1205      results of this function may seem unintuitive.
1206  
1207      Examples
1208      --------
1209      >>> from numpy.polynomial.hermite_e import hermeroots, hermefromroots
1210      >>> coef = hermefromroots([-1, 0, 1])
1211      >>> coef
1212      array([0., 2., 0., 1.])
1213      >>> hermeroots(coef)
1214      array([-1.,  0.,  1.]) # may vary
1215  
1216      rrGr3rNr%)
1217  r&r'r(r;r<rHr"�la�eigvals�sort)r6r`�rr.r.r/r�s3
1218  rc
1219  Cs�|dkrt�|jdt�t�dtj���Sd}dt�t�dtj��}t|�}t|d�D]!}|}|t�|d|�}|||t�d|�}|d}q/|||S)a�
1220      Evaluate a normalized HermiteE polynomial.
1221  
1222      Compute the value of the normalized HermiteE polynomial of degree ``n``
1223      at the points ``x``.
1224  
1225  
1226      Parameters
1227      ----------
1228      x : ndarray of double.
1229          Points at which to evaluate the function
1230      n : int
1231          Degree of the normalized HermiteE function to be evaluated.
1232  
1233      Returns
1234      -------
1235      values : ndarray
1236          The shape of the return value is described above.
1237  
1238      Notes
1239      -----
1240      .. versionadded:: 1.10.0
1241  
1242      This function is needed for finding the Gauss points and integration
1243      weights for high degrees. The values of the standard HermiteE functions
1244      overflow when n >= 207.
1245  
1246      rrr3r|r�)r;r�r_r��pi�floatr))rpr7r8r9rMr-r:r.r.r/�_normed_hermite_e_n�s$
1247  r�c	Cs�t�|d�}|dkrtd��t�dg|dg�}t|�}t�|�}t||�}t||d�t�	|�}|||8}t||d�}|t�
1248  |���}d||}||ddd�d}||ddd�d}|t�	dtj�|�
�9}||fS)a�
1249      Gauss-HermiteE quadrature.
1250  
1251      Computes the sample points and weights for Gauss-HermiteE quadrature.
1252      These sample points and weights will correctly integrate polynomials of
1253      degree :math:`2*deg - 1` or less over the interval :math:`[-\inf, \inf]`
1254      with the weight function :math:`f(x) = \exp(-x^2/2)`.
1255  
1256      Parameters
1257      ----------
1258      deg : int
1259          Number of sample points and weights. It must be >= 1.
1260  
1261      Returns
1262      -------
1263      x : ndarray
1264          1-D ndarray containing the sample points.
1265      y : ndarray
1266          1-D ndarray containing the weights.
1267  
1268      Notes
1269      -----
1270  
1271      .. versionadded:: 1.7.0
1272  
1273      The results have only been tested up to degree 100, higher degrees may
1274      be problematic. The weights are determined by using the fact that
1275  
1276      .. math:: w_k = c / (He'_n(x_k) * He_{n-1}(x_k))
1277  
1278      where :math:`c` is a constant independent of :math:`k` and :math:`x_k`
1279      is the k'th root of :math:`He_n`, and then scaling the results to get
1280      the right value when integrating 1.
1281  
1282      r+rzdeg must be a positive integerrNr%r3)r&r[r\r;r<r"r��eigvalshr�r��abs�maxr��sum)	r+r}r6r`rp�dy�df�fmr�r.r.r/r#s $
1283  
1284  r#cCst�d|d�}|S)a�Weight function of the Hermite_e polynomials.
1285  
1286      The weight function is :math:`\exp(-x^2/2)` and the interval of
1287      integration is :math:`[-\inf, \inf]`. the HermiteE polynomials are
1288      orthogonal, but not normalized, with respect to this weight function.
1289  
1290      Parameters
1291      ----------
1292      x : array_like
1293         Values at which the weight function will be computed.
1294  
1295      Returns
1296      -------
1297      w : ndarray
1298         The weight function at `x`.
1299  
1300      Notes
1301      -----
1302  
1303      .. versionadded:: 1.7.0
1304  
1305      g�r3)r;�exp)rpr�r.r.r/r$Ssr$c@s�eZdZdZee�Zee�Zee	�Z
1306  ee�Zee
�Zee�Zee�Zee�Zee�Zee�Zee�Zee�Ze�e�Z e�e�Z!dZ"dS)raAn HermiteE series class.
1307  
1308      The HermiteE class provides the standard Python numerical methods
1309      '+', '-', '*', '//', '%', 'divmod', '**', and '()' as well as the
1310      attributes and methods listed in the `ABCPolyBase` documentation.
1311  
1312      Parameters
1313      ----------
1314      coef : array_like
1315          HermiteE coefficients in order of increasing degree, i.e,
1316          ``(1, 2, 3)`` gives ``1*He_0(x) + 2*He_1(X) + 3*He_2(x)``.
1317      domain : (2,) array_like, optional
1318          Domain to use. The interval ``[domain[0], domain[1]]`` is mapped
1319          to the interval ``[window[0], window[1]]`` by shifting and scaling.
1320          The default value is [-1, 1].
1321      window : (2,) array_like, optional
1322          Window, see `domain` for its use. The default value is [-1, 1].
1323  
1324          .. versionadded:: 1.6.0
1325  
1326      ZHeN)#�__name__�
1327  __module__�__qualname__�__doc__�staticmethodrrBrrFr�_mulrrNrrPr�_valr�_intr�_derrr�r
1328  �_liner�_rootsrr?r;r<r	�domain�window�
1329  basis_namer.r.r.r/rrs"
1330  
1331  r)rO)rrr)T)NFN)0r��numpyr;�numpy.linalg�linalgr��numpy.core.multiarrayr�rr&�	_polybaser�__all__�trimcoefrrrr<r	rrrr
1332  rrrr
rrrrrrrrrrrr r!rr"rr�r#r$rr.r.r.r/�<module>sPM	.>'8((1B
1333  .
1334  %S
1335  z_1538<5
1336  6.@+C