관리-도구
편집 파일: legendre.cpython-37.pyc
B ��Fdo� � @ s� d Z ddlmZmZmZ ddlZddlZddlm Z ddlmZ ddl mZ ddlmZ dd d ddd ddddddddddddddddddd d!d"d#d$d%d&gZejZd'd� Zd(d� Ze�d)dg�Ze�dg�Ze�dg�Ze�ddg�Zd*d� Zd+d� Zd,d � Zd-d� Zd.d� Z d/d� Z!d0d� Z"dEd2d�Z#dFd3d�Z$dg dddfd4d�Z%dGd6d�Z&d7d� Z'd8d � Z(d9d� Z)d:d!� Z*d;d� Z+d<d"� Z,d=d#� Z-dHd?d�Z.d@d$� Z/dAd� Z0dBd%� Z1dCd&� Z2G dDd� de�Z3dS )Ia� Legendre Series (:mod: `numpy.polynomial.legendre`) =================================================== .. currentmodule:: numpy.polynomial.polynomial This module provides a number of objects (mostly functions) useful for dealing with Legendre series, including a `Legendre` class that encapsulates the usual arithmetic operations. (General information on how this module represents and works with such polynomials is in the docstring for its "parent" sub-package, `numpy.polynomial`). Constants --------- .. autosummary:: :toctree: generated/ legdomain Legendre series default domain, [-1,1]. legzero Legendre series that evaluates identically to 0. legone Legendre series that evaluates identically to 1. legx Legendre series for the identity map, ``f(x) = x``. Arithmetic ---------- .. autosummary:: :toctree: generated/ legmulx multiply a Legendre series in P_i(x) by x. legadd add two Legendre series. legsub subtract one Legendre series from another. legmul multiply two Legendre series. legdiv divide one Legendre series by another. legpow raise a Legendre series to an positive integer power legval evaluate a Legendre series at given points. legval2d evaluate a 2D Legendre series at given points. legval3d evaluate a 3D Legendre series at given points. leggrid2d evaluate a 2D Legendre series on a Cartesian product. leggrid3d evaluate a 3D Legendre series on a Cartesian product. Calculus -------- .. autosummary:: :toctree: generated/ legder differentiate a Legendre series. legint integrate a Legendre series. Misc Functions -------------- .. autosummary:: :toctree: generated/ legfromroots create a Legendre series with specified roots. legroots find the roots of a Legendre series. legvander Vandermonde-like matrix for Legendre polynomials. legvander2d Vandermonde-like matrix for 2D power series. legvander3d Vandermonde-like matrix for 3D power series. leggauss Gauss-Legendre quadrature, points and weights. legweight Legendre weight function. legcompanion symmetrized companion matrix in Legendre form. legfit least-squares fit returning a Legendre series. legtrim trim leading coefficients from a Legendre series. legline Legendre series representing given straight line. leg2poly convert a Legendre series to a polynomial. poly2leg convert a polynomial to a Legendre series. Classes ------- Legendre A Legendre series class. See also -------- numpy.polynomial.polynomial numpy.polynomial.chebyshev numpy.polynomial.laguerre numpy.polynomial.hermite numpy.polynomial.hermite_e � )�division�absolute_import�print_functionN)�normalize_axis_index� )� polyutils)�ABCPolyBase�legzero�legone�legx� legdomain�legline�legadd�legsub�legmulx�legmul�legdiv�legpow�legval�legder�legint�leg2poly�poly2leg�legfromroots� legvander�legfit�legtrim�legroots�Legendre�legval2d�legval3d� leggrid2d� leggrid3d�legvander2d�legvander3d�legcompanion�leggauss� legweightc C sJ t �| g�\} t| �d }d}x&t|dd�D ]}tt|�| | �}q,W |S )a� Convert a polynomial to a Legendre series. Convert an array representing the coefficients of a polynomial (relative to the "standard" basis) ordered from lowest degree to highest, to an array of the coefficients of the equivalent Legendre series, ordered from lowest to highest degree. Parameters ---------- pol : array_like 1-D array containing the polynomial coefficients Returns ------- c : ndarray 1-D array containing the coefficients of the equivalent Legendre series. See Also -------- leg2poly Notes ----- The easy way to do conversions between polynomial basis sets is to use the convert method of a class instance. Examples -------- >>> from numpy import polynomial as P >>> p = P.Polynomial(np.arange(4)) >>> p Polynomial([ 0., 1., 2., 3.], [-1., 1.]) >>> c = P.Legendre(P.poly2leg(p.coef)) >>> c Legendre([ 1. , 3.25, 1. , 0.75], [-1., 1.]) r r ���)�pu� as_series�len�ranger r )Zpol�deg�res�i� r0 �L/opt/alt/python37/lib64/python3.7/site-packages/numpy/polynomial/legendre.pyr i s (c C s� ddl m}m}m} t�| g�\} t| �}|dk r6| S | d }| d }xXt|d dd�D ]D}|}|| |d ||d | �}||||�d| d | �}qXW ||||��S dS )a� Convert a Legendre series to a polynomial. Convert an array representing the coefficients of a Legendre series, ordered from lowest degree to highest, to an array of the coefficients of the equivalent polynomial (relative to the "standard" basis) ordered from lowest to highest degree. Parameters ---------- c : array_like 1-D array containing the Legendre series coefficients, ordered from lowest order term to highest. Returns ------- pol : ndarray 1-D array containing the coefficients of the equivalent polynomial (relative to the "standard" basis) ordered from lowest order term to highest. See Also -------- poly2leg Notes ----- The easy way to do conversions between polynomial basis sets is to use the convert method of a class instance. Examples -------- >>> c = P.Legendre(range(4)) >>> c Legendre([ 0., 1., 2., 3.], [-1., 1.]) >>> p = c.convert(kind=P.Polynomial) >>> p Polynomial([-1. , -3.5, 3. , 7.5], [-1., 1.]) >>> P.leg2poly(range(4)) array([-1. , -3.5, 3. , 7.5]) r )�polyadd�polysub�polymulx� ���r( � N)� polynomialr2 r3 r4 r) r* r+ r, ) �cr2 r3 r4 �n�c0�c1r/ �tmpr0 r0 r1 r � s ,"r( c C s&