Safe Haskell | None |
---|---|
Language | Haskell2010 |
- Sparsify : remove almost-0 elements (|x| < eps)
- Matrix condition number
- Householder transformation
- Givens rotation matrix
- QR decomposition
- Eigenvalue algorithms
- Householder vector
- Householder bidiagonalization
- SVD
- LU factorization
- Iterative linear solvers
- Moore-Penrose pseudoinverse
- Linear solver interface
- Control primitives for bounded iteration with convergence check
- Random matrices and vectors
- Pretty printing
- Type synonyms for SpMatrix
- sparsifySV :: SpVector Double -> SpVector Double
- conditionNumberSM :: SpMatrix Double -> Double
- hhMat :: Num a => a -> SpVector a -> SpMatrix a
- hhRefl :: SpVector Double -> SpMatrix Double
- hypot :: Floating a => a -> a -> a
- sign :: (Ord a, Num a) => a -> a
- givensCoef :: (Ord a, Floating a) => a -> a -> (a, a, a)
- givens :: SpMatrix Double -> IxRow -> IxCol -> SpMatrix Double
- firstNonZeroColumn :: IntMap a -> IxRow -> Bool
- candidateRows :: IntMap (IntMap a) -> IxRow -> IxCol -> Maybe [Key]
- qr :: SpMatrix Double -> (SpMatrix Double, SpMatrix Double)
- gmats :: SpMatrix Double -> [SpMatrix Double]
- eigsQR :: Int -> SpMatrix Double -> SpVector Double
- eigRayleigh :: Int -> SpMatrix Double -> (SpVector Double, Double) -> (SpVector Double, Double)
- hhV :: SpVector Double -> (SpVector Double, Double)
- permutAA :: Num b => SpMatrix a -> IxRow -> IxCol -> Maybe (SpMatrix b)
- bcgStep :: SpMatrix Double -> BCG -> BCG
- data BCG = BCG {}
- bcg :: SpMatrix Double -> SpVector Double -> SpVector Double -> BCG
- cgsStep :: SpMatrix Double -> SpVector Double -> CGS -> CGS
- data CGS = CGS {}
- cgs :: SpMatrix Double -> SpVector Double -> SpVector Double -> SpVector Double -> CGS
- bicgstabStep :: SpMatrix Double -> SpVector Double -> BICGSTAB -> BICGSTAB
- data BICGSTAB = BICGSTAB {}
- bicgstab :: SpMatrix Double -> SpVector Double -> SpVector Double -> SpVector Double -> BICGSTAB
- pinv :: SpMatrix Double -> SpVector Double -> SpVector Double
- data LinSolveMethod
- linSolve :: LinSolveMethod -> SpMatrix Double -> SpVector Double -> SpVector Double
- (<\>) :: SpMatrix Double -> SpVector Double -> SpVector Double
- modifyUntil :: MonadState s m => (s -> Bool) -> (s -> s) -> m s
- loopUntilAcc :: Int -> ([t] -> Bool) -> (t -> t) -> t -> t
- modifyInspectN :: MonadState s m => Int -> ([s] -> Bool) -> (s -> s) -> m s
- meanl :: (Foldable t, Fractional a) => t a -> a
- norm2l :: (Foldable t, Functor t, Floating a) => t a -> a
- diffSqL :: Floating a => [a] -> a
- untilConverged :: MonadState a m => (a -> SpVector Double) -> (a -> a) -> m a
- normDiffConverged :: (Foldable t, Functor t) => (a -> SpVector Double) -> t a -> Bool
- runAppendN :: ([t] -> Bool) -> (t -> t) -> Int -> t -> [t]
- runAppendN' :: (t -> t) -> Int -> t -> [t]
- randMat :: PrimMonad m => Int -> m (SpMatrix Double)
- randVec :: PrimMonad m => Int -> m (SpVector Double)
- randSpMat :: Int -> Int -> IO (SpMatrix Double)
- randSpVec :: Int -> Int -> IO (SpVector Double)
- showNonZero :: (Show a, Num a, Eq a) => a -> String
- toDenseRow :: Num a => SpMatrix a -> Key -> [a]
- toDenseRowClip :: (Show a, Num a) => SpMatrix a -> Key -> Int -> String
- newline :: IO ()
- printDenseSM :: (Show t, Num t) => SpMatrix t -> IO ()
- toDenseListClip :: (Show a, Num a) => SpVector a -> Int -> String
- printDenseSV :: (Show t, Num t) => SpVector t -> IO ()
- class PrintDense a where
Sparsify : remove almost-0 elements (|x| < eps)
Matrix condition number
Householder transformation
hhRefl :: SpVector Double -> SpMatrix Double Source #
a vector x
uniquely defines an orthogonal plane; the Householder operator reflects any point v
with respect to this plane:
v' = (I - 2 x >< x) v
Givens rotation matrix
givensCoef :: (Ord a, Floating a) => a -> a -> (a, a, a) Source #
Givens coefficients (using stable algorithm shown in Anderson, Edward (4 December 2000). "Discontinuous Plane Rotations and the Symmetric Eigenvalue Problem". LAPACK Working Note)
givens :: SpMatrix Double -> IxRow -> IxCol -> SpMatrix Double Source #
Givens method, row version: choose other row index i' s.t. i' is : * below the diagonal * corresponding element is nonzero
QR.C1 ) To zero out entry A(i, j) we must find row k such that A(k, j) is non-zero but A has zeros in row k for all columns less than j.
firstNonZeroColumn :: IntMap a -> IxRow -> Bool Source #
Is the k
th the first nonzero column in the row?
candidateRows :: IntMap (IntMap a) -> IxRow -> IxCol -> Maybe [Key] Source #
Returns a set of rows {k} that satisfy QR.C1
QR decomposition
qr :: SpMatrix Double -> (SpMatrix Double, SpMatrix Double) Source #
Applies Givens rotation iteratively to zero out sub-diagonal elements
Eigenvalue algorithms
All eigenvalues (QR algorithm)
eigsQR :: Int -> SpMatrix Double -> SpVector Double Source #
`eigsQR n mm` performs n
iterations of the QR algorithm on matrix mm
One eigenvalue and eigenvector (Rayleigh iteration)
eigRayleigh :: Int -> SpMatrix Double -> (SpVector Double, Double) -> (SpVector Double, Double) Source #
`eigsRayleigh n mm` performs n
iterations of the Rayleigh algorithm on matrix mm
. Cubic-order convergence, but it requires a mildly educated guess on the initial eigenpair
Householder vector
Householder bidiagonalization
SVD
LU factorization
Iterative linear solvers
BCG
CGS
cgs :: SpMatrix Double -> SpVector Double -> SpVector Double -> SpVector Double -> CGS Source #
iterate solver until convergence or until max # of iterations is reached
BiCGSTAB
bicgstabStep :: SpMatrix Double -> SpVector Double -> BICGSTAB -> BICGSTAB Source #
one step of BiCGSTAB
bicgstab :: SpMatrix Double -> SpVector Double -> SpVector Double -> SpVector Double -> BICGSTAB Source #
iterate solver until convergence or until max # of iterations is reached
Moore-Penrose pseudoinverse
pinv :: SpMatrix Double -> SpVector Double -> SpVector Double Source #
Least-squares approximation of a rectangular system of equaitons. Uses \ for the linear solve
Linear solver interface
data LinSolveMethod Source #
linSolve :: LinSolveMethod -> SpMatrix Double -> SpVector Double -> SpVector Double Source #
Linear solve with _deterministic_ starting vector (every component at 0.1)
(<\>) :: SpMatrix Double -> SpVector Double -> SpVector Double Source #
\ : linSolve using the BiCGSTAB method as default
Control primitives for bounded iteration with convergence check
modifyUntil :: MonadState s m => (s -> Bool) -> (s -> s) -> m s Source #
transform state until a condition is met
loopUntilAcc :: Int -> ([t] -> Bool) -> (t -> t) -> t -> t Source #
Keep a moving window buffer (length 2) of state x
to assess convergence, stop when either a condition on that list is satisfied or when max # of iterations is reached
modifyInspectN :: MonadState s m => Int -> ([s] -> Bool) -> (s -> s) -> m s Source #
Keep a moving window buffer (length 2) of state x
to assess convergence, stop when either a condition on that list is satisfied or when max # of iterations is reached (i.e. same thing as loopUntilAcc
but this one runs in the State monad)
meanl :: (Foldable t, Fractional a) => t a -> a Source #
untilConverged :: MonadState a m => (a -> SpVector Double) -> (a -> a) -> m a Source #
iterate until convergence is verified or we run out of a fixed iteration budget
normDiffConverged :: (Foldable t, Functor t) => (a -> SpVector Double) -> t a -> Bool Source #
convergence check (FIXME)
runAppendN :: ([t] -> Bool) -> (t -> t) -> Int -> t -> [t] Source #
run niter
iterations and append the state x
to a list xs
, stop when either the xs
satisfies a predicate q
or when the counter reaches 0
runAppendN' :: (t -> t) -> Int -> t -> [t] Source #
", NO convergence check
Random matrices and vectors
Pretty printing
Pretty printer typeclass
class PrintDense a where Source #