Safe Haskell | None |
---|---|
Language | Haskell98 |
Some numerical computations used by the cubic bezier functions
- sign :: (Ord a, Num a1, Num a) => a -> a1
- quadraticRoot :: Double -> Double -> Double -> [Double]
- solveLinear2x2 :: (Eq a, Fractional a) => a -> a -> a -> a -> a -> a -> Maybe (a, a)
- data SparseMatrix a = SparseMatrix (Vector Int) (Vector (Int, Int)) (Matrix a)
- makeSparse :: Unbox a => Vector Int -> Matrix a -> SparseMatrix a
- sparseRanges :: Vector Int -> Int -> Int -> Vector (Int, Int)
- lsqMatrix :: (Num a, Unbox a) => SparseMatrix a -> Matrix a
- addMatrix :: (Num a, Unbox a) => Matrix a -> Matrix a -> Matrix a
- addVec :: (Num a, Unbox a) => Vector a -> Vector a -> Vector a
- sparseMulT :: (Num a, Unbox a) => Vector a -> SparseMatrix a -> Vector a
- sparseMul :: (Num a, Unbox a) => SparseMatrix a -> Vector a -> Vector a
- decompLDL :: (Fractional a, Unbox a) => Matrix a -> Matrix a
- solveLDL :: (Fractional a, Unbox a) => Matrix a -> Vector a -> Vector a
- lsqSolve :: (Fractional a, Unbox a) => SparseMatrix a -> Vector a -> Vector a
- lsqSolveDist :: (Fractional a, Unbox a) => SparseMatrix (a, a) -> Vector (a, a) -> Vector a
Documentation
quadraticRoot :: Double -> Double -> Double -> [Double] Source
quadraticRoot a b c
find the real roots of the quadratic equation
a x^2 + b x + c = 0
. It will return one, two or zero roots.
solveLinear2x2 :: (Eq a, Fractional a) => a -> a -> a -> a -> a -> a -> Maybe (a, a) Source
solveLinear2x2 a b c d e f
solves the linear equation with two variables (x and y) and two systems:
a x + b y + c = 0 d x + e y + f = 0
Returns Nothing
if no solution is found.
data SparseMatrix a Source
:: Unbox a | |
=> Vector Int | The column index of the first element of each row. Should be ascending in order. |
-> Matrix a | The adjacent coefficients in each row |
-> SparseMatrix a | A sparse matrix. |
:: (Num a, Unbox a) | |
=> SparseMatrix a | The input system. |
-> Matrix a | The resulting symmetric matrix as a sparse matrix. The first element of each row is the element on the diagonal. |
Given a rectangular matrix M, calculate the symmetric square matrix MᵀM which can be used to find a least squares solution to the overconstrained system.
sparseMulT :: (Num a, Unbox a) => Vector a -> SparseMatrix a -> Vector a Source
Multiply the vector by the transpose of the sparse matrix.
sparseMul :: (Num a, Unbox a) => SparseMatrix a -> Vector a -> Vector a Source
Sparse matrix * vector multiplication.
decompLDL :: (Fractional a, Unbox a) => Matrix a -> Matrix a Source
LDL* decomposition of the sparse hermitian matrix. The first element of each row is the diagonal component of the D matrix. The following elements are the elements next to the diagonal in the L* matrix (the diagonal components in L* are 1). For efficiency it mutates the matrix inplace.
:: (Fractional a, Unbox a) | |
=> SparseMatrix a | sparse matrix |
-> Vector a | Right hand side vector. |
-> Vector a | Solution vector |
lsqSolve rowStart M y
Find a least squares solution x to the
system xM = y.
:: (Fractional a, Unbox a) | |
=> SparseMatrix (a, a) | sparse matrix |
-> Vector (a, a) | Right hand side vector. |
-> Vector a | Solution vector |
lsqSolveDist rowStart M y
Find a least squares solution of the distance between the points.