Lagrange polynomials over finite fields
Project description
Lagrange Polynomials
Module to generate Lagrange polynomials over integers for 1-dimensional data. This is generally useful for interpolation.
Installation
Install with pip
.
Usage
Example
from lagrange_polynomial import LagrangePolynomial
xs = range(100)
ys = [f(x) for x in xs] # For some function f
lp = LagrangePolynomial(xs, ys) # Instantiate a polynomial with sequences of
# x- and y-coordinates.
for x in xs:
assert ys[x] == lp(x) # Polynomial will intersect original points
coefficient = lp.basis[0](x) # Get the 0th basis vector at x
Interface
The LagrangePolynomial
class takes two equally-sized sequences and an optional integer p.
The instance is a Lagrange polynomial L: x -> L(x) over GF(p). If p is not provided, it defaults to the 8th Mersenne prime M31.
It has a basis
property, a LagrangeBasis
object subclassing Sequence
.
Each element ℓⱼ indexed by integers j in range(len(xs))
is a function taking x to its jth basis vector ℓⱼ(x).
Test
Test with make test
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for lagrange_polynomial-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35d851dcc3e67f978e2a3827a93810632c73f3eef90b8bff656956974e7b78b7 |
|
MD5 | 3c644e914884816af76b8f550657190e |
|
BLAKE2b-256 | d5f9e42033444b363d3911ccd9c560c39c3a0d528cc709518cbb44c8886731f2 |
Close
Hashes for lagrange_polynomial-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 850b702ea1aabcfc0d6f82dd4a64387b8cff7c386d2198f3fac8176ea31bea32 |
|
MD5 | 68f313b707aafa09e75b4277aab8fc1d |
|
BLAKE2b-256 | a88a24d409ecb2d1b1a4985371571c8281ff85addd0b71b4954ad85fcbc52475 |