qmat.lagrange ============= .. py:module:: qmat.lagrange .. autoapi-nested-parse:: Base module for Barycentric Lagrange Approximation, based on `[Berrut & Trefethen, 2004] `_. Allows to easily build integration / interpolation / derivative matrices, from any list of node points. .. rubric:: Examples >>> # Base usage to generate a quadrature matrix >>> from qmat.lagrange import LagrangeApproximation, np >>> >>> grid = np.linspace(0, 1, num=5) >>> approx = LagrangeApproximation(grid) >>> Q = approx.getIntegrationMatrix([(0, tau) for tau in grid]) >>> >>> # Interpolation >>> fGrid = np.linspace(0, 1, num=200) >>> u = np.exp(grid) >>> P = approx.getInterpolationMatrix(fGrid) >>> uFine = P @ u >>> >>> # Alternative interpolation using the object as a function >>> uFine = approx(fGrid) >>> >>> # Derivative >>> D = approx.getDerivativeMatrix() >>> du = D @ u Classes ------- .. autoapisummary:: qmat.lagrange.LagrangeApproximation Functions --------- .. autoapisummary:: qmat.lagrange.computeFejerRule qmat.lagrange.getSparseInterpolationMatrix Module Contents --------------- .. py:function:: computeFejerRule(n) Compute a Fejer rule of the first kind, using DFT `[Waldvogel, 2006] `_. Inspired from quadpy (https://github.com/nschloe/quadpy @Nico_Schlömer) :Parameters: **n** (*int*) -- Number of points for the quadrature rule. :returns: * **nodes** (*np.1darray(n)*) -- The nodes of the quadrature rule * **weights** (*np.1darray(n)*) -- The weights of the quadrature rule. .. py:class:: LagrangeApproximation(points, weightComputation='AUTO', scaleWeights=False, scaleRef='MAX', duplicates='USE_LEFT', fValues=None) Class approximating any function on a given set of points using barycentric Lagrange interpolation. Let note :math:`(t_j)_{0\leq j