Safe Haskell | None |
---|---|

Language | Haskell98 |

Algebra on polynomials in the Bernstein form. It is based on the paper /Algebraic manipulation in the Bernstein form made simple via convolutions/ by J. Sanchez-Reyes. It's an efficient implementation using the scaled basis, and using ghc rewrite rules to eliminate intermediate polynomials.

## Synopsis

- data BernsteinPoly a = BernsteinPoly {
- bernsteinCoeffs :: Vector a

- bernsteinSubsegment :: (Unbox a, Ord a, Fractional a) => BernsteinPoly a -> a -> a -> BernsteinPoly a
- listToBernstein :: (Unbox a, Num a) => [a] -> BernsteinPoly a
- zeroPoly :: (Num a, Unbox a) => BernsteinPoly a
- (~*) :: (Unbox a, Fractional a) => BernsteinPoly a -> BernsteinPoly a -> BernsteinPoly a
- (*~) :: (Unbox a, Num a) => a -> BernsteinPoly a -> BernsteinPoly a
- (~+) :: (Unbox a, Fractional a) => BernsteinPoly a -> BernsteinPoly a -> BernsteinPoly a
- (~-) :: (Unbox a, Fractional a) => BernsteinPoly a -> BernsteinPoly a -> BernsteinPoly a
- degreeElevate :: (Unbox a, Fractional a) => BernsteinPoly a -> Int -> BernsteinPoly a
- bernsteinSplit :: (Unbox a, Num a) => BernsteinPoly a -> a -> (BernsteinPoly a, BernsteinPoly a)
- bernsteinEval :: (Unbox a, Fractional a) => BernsteinPoly a -> a -> a
- bernsteinEvalDeriv :: (Unbox t, Fractional t) => BernsteinPoly t -> t -> (t, t)
- binCoeff :: (Num a, Unbox a) => Int -> Vector a
- convolve :: (Unbox a, Num a) => Vector a -> Vector a -> Vector a
- bernsteinEvalDerivs :: (Unbox t, Fractional t) => BernsteinPoly t -> t -> [t]
- bernsteinDeriv :: (Unbox a, Num a) => BernsteinPoly a -> BernsteinPoly a

# Documentation

data BernsteinPoly a Source #

## Instances

(Show a, Unbox a) => Show (BernsteinPoly a) Source # | |

Defined in Math.BernsteinPoly showsPrec :: Int -> BernsteinPoly a -> ShowS # show :: BernsteinPoly a -> String # showList :: [BernsteinPoly a] -> ShowS # |

bernsteinSubsegment :: (Unbox a, Ord a, Fractional a) => BernsteinPoly a -> a -> a -> BernsteinPoly a Source #

Return the subsegment between the two parameters.

listToBernstein :: (Unbox a, Num a) => [a] -> BernsteinPoly a Source #

Create a bernstein polynomail from a list of coëfficients.

(~*) :: (Unbox a, Fractional a) => BernsteinPoly a -> BernsteinPoly a -> BernsteinPoly a infixl 7 Source #

Multiply two bernstein polynomials using convolution. The final degree will be the sum of either degrees. This operation takes O((n+m)^2) with n and m the degree of the beziers. Note that convolution can be done in O(n log n) using the FFT, which may be faster for large polynomials.

(*~) :: (Unbox a, Num a) => a -> BernsteinPoly a -> BernsteinPoly a infixl 7 Source #

Scale a bernstein polynomial by a constant.

(~+) :: (Unbox a, Fractional a) => BernsteinPoly a -> BernsteinPoly a -> BernsteinPoly a infixl 6 Source #

Sum two bernstein polynomials. The final degree will be the maximum of either degrees.

(~-) :: (Unbox a, Fractional a) => BernsteinPoly a -> BernsteinPoly a -> BernsteinPoly a infixl 6 Source #

Subtract two bernstein polynomials. The final degree will be the maximum of either degrees.

degreeElevate :: (Unbox a, Fractional a) => BernsteinPoly a -> Int -> BernsteinPoly a Source #

bernsteinSplit :: (Unbox a, Num a) => BernsteinPoly a -> a -> (BernsteinPoly a, BernsteinPoly a) Source #

Split a bernstein polynomial

bernsteinEval :: (Unbox a, Fractional a) => BernsteinPoly a -> a -> a Source #

Evaluate the bernstein polynomial using the horner rule adapted for bernstein polynomials.

bernsteinEvalDeriv :: (Unbox t, Fractional t) => BernsteinPoly t -> t -> (t, t) Source #

Evaluate the bernstein polynomial and first derivative

convolve :: (Unbox a, Num a) => Vector a -> Vector a -> Vector a Source #

Calculate the convolution of two vectors.

bernsteinEvalDerivs :: (Unbox t, Fractional t) => BernsteinPoly t -> t -> [t] Source #

Evaluate the bernstein polynomial and its derivatives.

bernsteinDeriv :: (Unbox a, Num a) => BernsteinPoly a -> BernsteinPoly a Source #

Find the derivative of a bernstein polynomial.