Safe Haskell | None |
---|---|
Language | Haskell2010 |
- Additive ring
- Vector space
- Hilbert space (inner product)
- Normed vector space
- FiniteDim : finite-dimensional objects
- HasData : accessing inner data (do not export)
- Sparse : sparse datastructures
- Set : things that behave as sets
- Sparse Vector
- Element insertion
- Sparse Matrix
- fromList
- toList
- Primitive algebra operations
- Matrix condition number
- Householder transformation
- Givens rotation matrix
- QR decomposition
- Eigenvalue algorithms
- Householder vector (G & VL Alg. 5.1.1, function
house
) - SVD
- Iterative linear solvers
- Linear solver interface
- Control primitives for bounded iteration with convergence check
- Rounding operations
- Random matrices and vectors
- Pretty printing
- Misc. utilities
- class Functor f => Additive f where
- negated :: (Num a, Functor f) => f a -> f a
- (^-^) :: (Additive f, Num a) => f a -> f a -> f a
- class Additive f => VectorSpace f where
- lerp :: (VectorSpace f, Num a) => a -> f a -> f a -> f a
- class VectorSpace f => Hilbert f where
- class Hilbert f => Normed f where
- normSq :: (Hilbert f, Num a) => f a -> a
- norm1 :: (Foldable t, Num a, Functor t) => t a -> a
- norm2 :: (Hilbert f, Floating a) => f a -> a
- normP :: (Foldable t, Functor t, Floating a) => a -> t a -> a
- normInfty :: (Foldable t, Ord a) => t a -> a
- normalize :: (Normed f, Floating a, Eq a) => a -> f a -> f a
- dotLp :: (Set t, Foldable t, Floating a) => a -> t a -> t a -> a
- reciprocal :: (Functor f, Fractional b) => f b -> f b
- scale :: (Num b, Functor f) => b -> f b -> f b
- class Additive f => FiniteDim f where
- withDim :: (FiniteDim f, Show e) => f a -> (FDSize f -> f a -> Bool) -> (f a -> c) -> String -> (f a -> e) -> c
- withDim2 :: (FiniteDim f, FiniteDim g, Show e) => f a -> g b -> (FDSize f -> FDSize g -> f a -> g b -> Bool) -> (f a -> g b -> c) -> String -> (f a -> g b -> e) -> c
- class Additive f => HasData f a where
- class (FiniteDim f, HasData f a) => Sparse f a where
- class Functor f => Set f where
- data SpVector a = SV {}
- spySV :: Fractional b => SpVector a -> b
- zeroSV :: Int -> SpVector a
- singletonSV :: a -> SpVector a
- mkSpVector :: (Num a, Eq a) => Int -> IntMap a -> SpVector a
- mkSpVectorD :: (Num a, Eq a) => Int -> [a] -> SpVector a
- mkSpVector1 :: Int -> IntMap a -> SpVector a
- fromListDenseSV :: Int -> [a] -> SpVector a
- onesSV :: Num a => Int -> SpVector a
- zerosSV :: Num a => Int -> SpVector a
- insertSpVector :: Int -> a -> SpVector a -> SpVector a
- fromListSV :: Int -> [(Int, a)] -> SpVector a
- toListSV :: SpVector a -> [(Key, a)]
- toDenseListSV :: Num b => SpVector b -> [b]
- lookupDenseSV :: Num a => Key -> SpVector a -> a
- tailSV :: SpVector a -> SpVector a
- headSV :: Num a => SpVector a -> a
- concatSV :: SpVector a -> SpVector a -> SpVector a
- svToSM :: SpVector a -> SpMatrix a
- outerProdSV :: Num a => SpVector a -> SpVector a -> SpMatrix a
- (><) :: Num a => SpVector a -> SpVector a -> SpMatrix a
- data SpMatrix a = SM {}
- maxTup :: Ord t => (t, t) -> (t, t) -> (t, t)
- minTup :: Ord t => (t, t) -> (t, t) -> (t, t)
- emptySpMatrix :: (Int, Int) -> SpMatrix a
- zeroSM :: Int -> Int -> SpMatrix a
- mkDiagonal :: Int -> [a] -> SpMatrix a
- eye :: Num a => Int -> SpMatrix a
- mkSubDiagonal :: Int -> Int -> [a] -> SpMatrix a
- fromListSM' :: Foldable t => t (IxRow, IxCol, a) -> SpMatrix a -> SpMatrix a
- fromListSM :: Foldable t => (Int, Int) -> t (IxRow, IxCol, a) -> SpMatrix a
- fromListDenseSM :: Int -> [a] -> SpMatrix a
- toDenseListSM :: Num t => SpMatrix t -> [(IxRow, IxCol, t)]
- insertSpMatrix :: IxRow -> IxCol -> a -> SpMatrix a -> SpMatrix a
- lookupSM :: SpMatrix a -> IxRow -> IxCol -> Maybe a
- lookupWD_SM :: Num a => SpMatrix a -> (IxRow, IxCol) -> a
- (@@) :: Num a => SpMatrix a -> (IxRow, IxCol) -> a
- lookupWD_IM :: Num a => IntMap (IntMap a) -> (IxRow, IxCol) -> a
- matScale :: Num a => a -> SpMatrix a -> SpMatrix a
- normFrobenius :: SpMatrix Double -> Double
- type Rows = Int
- type Cols = Int
- type IxRow = Int
- type IxCol = Int
- validIxSM :: SpMatrix a -> (Int, Int) -> Bool
- isSquareSM :: SpMatrix a -> Bool
- isDiagonalSM :: SpMatrix a -> Bool
- isOrthogonalSM :: SpMatrix Double -> Bool
- immSM :: SpMatrix t -> IntMap (IntMap t)
- dimSM :: SpMatrix t -> (Rows, Cols)
- nelSM :: SpMatrix t -> Int
- nrows :: SpMatrix a -> Rows
- ncols :: SpMatrix a -> Cols
- data SMInfo = SMInfo {}
- infoSM :: SpMatrix a -> SMInfo
- nzSM :: SpMatrix a -> Int
- spySM :: Fractional b => SpMatrix a -> b
- nzRow :: SpMatrix a -> Key -> Int
- bwMinSM :: SpMatrix a -> Int
- bwMaxSM :: SpMatrix a -> Int
- bwBoundsSM :: SpMatrix a -> (Int, Int)
- extractSubmatrixSM :: SpMatrix a -> (IxRow, IxCol) -> (IxRow, IxCol) -> SpMatrix a
- toSV :: SpMatrix a -> SpVector a
- extractColSM :: SpMatrix a -> IxCol -> SpMatrix a
- extractCol :: SpMatrix a -> IxCol -> SpVector a
- extractRowSM :: SpMatrix a -> IxRow -> SpMatrix a
- extractRow :: SpMatrix a -> IxRow -> SpVector a
- vertStackSM :: SpMatrix a -> SpMatrix a -> SpMatrix a
- (-=-) :: SpMatrix a -> SpMatrix a -> SpMatrix a
- horizStackSM :: SpMatrix a -> SpMatrix a -> SpMatrix a
- (-||-) :: SpMatrix a -> SpMatrix a -> SpMatrix a
- foldlSM :: (a -> b -> b) -> b -> SpMatrix a -> b
- ifoldlSM :: (Key -> Key -> a -> b -> b) -> b -> SpMatrix a -> b
- countSubdiagonalNZSM :: SpMatrix a -> Int
- extractDiagonalDSM :: Num a => SpMatrix a -> SpVector a
- subdiagIndicesSM :: SpMatrix a -> [(Key, Key)]
- sparsifyIM2 :: IntMap (IntMap Double) -> IntMap (IntMap Double)
- sparsifySM :: SpMatrix Double -> SpMatrix Double
- roundZeroOneSM :: SpMatrix Double -> SpMatrix Double
- transposeSM :: SpMatrix a -> SpMatrix a
- (#^) :: SpMatrix a -> SpMatrix a
- matVec :: Num a => SpMatrix a -> SpVector a -> SpVector a
- (#>) :: Num a => SpMatrix a -> SpVector a -> SpVector a
- vecMat :: Num a => SpVector a -> SpMatrix a -> SpVector a
- (<#) :: Num a => SpVector a -> SpMatrix a -> SpVector a
- matMat :: Num a => SpMatrix a -> SpMatrix a -> SpMatrix a
- (##) :: Num a => SpMatrix a -> SpMatrix a -> SpMatrix a
- matMatSparsified :: SpMatrix Double -> SpMatrix Double -> SpMatrix Double
- (#~#) :: SpMatrix Double -> SpMatrix Double -> SpMatrix Double
- (#^#) :: SpMatrix Double -> SpMatrix Double -> SpMatrix Double
- (##^) :: SpMatrix Double -> SpMatrix Double -> SpMatrix 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
- rayleighStep :: SpMatrix Double -> (SpVector Double, Double) -> (SpVector Double, Double)
- eigRayleigh :: Int -> SpMatrix Double -> (SpVector Double, Double) -> (SpVector Double, Double)
- hhV :: SpVector Double -> (SpVector Double, Double)
- eps :: Double
- residual :: Num a => SpMatrix a -> SpVector a -> SpVector a -> SpVector a
- converged :: SpMatrix Double -> SpVector Double -> SpVector Double -> Bool
- 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
- data LinSolveMethod
- linSolveM :: PrimMonad m => LinSolveMethod -> SpMatrix Double -> SpVector Double -> m (SpVector Double)
- 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]
- almostZero :: Double -> Bool
- almostOne :: Double -> Bool
- withDefault :: (t -> Bool) -> t -> t -> t
- roundZero :: Double -> Double
- roundOne :: Double -> Double
- with2Defaults :: (t -> Bool) -> (t -> Bool) -> t -> t -> t -> t
- roundZeroOne :: Double -> Double
- 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)
- sizeStr :: SpMatrix a -> String
- 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
- denseIxArray :: [b] -> [(Int, b)]
- denseIxArray2 :: Int -> [c] -> [(Int, Int, c)]
- foldrMap :: (Foldable t, Functor t) => (a -> b) -> (b -> c -> c) -> c -> t a -> c
- foldlStrict :: (a -> b -> a) -> a -> [b] -> a
- ifoldr :: Num i => (a -> b -> b) -> b -> (i -> c -> d -> a) -> c -> [d] -> b
- type LB = Int
- type UB = Int
- inBounds :: LB -> UB -> Int -> Bool
- inBounds2 :: (LB, UB) -> (Int, Int) -> Bool
- inBounds0 :: UB -> Int -> Bool
- inBounds02 :: (UB, UB) -> (Int, Int) -> Bool
Additive ring
Vector space
class Additive f => VectorSpace f where Source #
lerp :: (VectorSpace f, Num a) => a -> f a -> f a -> f a Source #
linear interpolation
Hilbert space (inner product)
class VectorSpace f => Hilbert f where Source #
Normed vector space
Norms and related results
normalize :: (Normed f, Floating a, Eq a) => a -> f a -> f a Source #
Normalize w.r.t. p-norm (p finite)
reciprocal :: (Functor f, Fractional b) => f b -> f b Source #
Reciprocal
FiniteDim : finite-dimensional objects
withDim :: (FiniteDim f, Show e) => f a -> (FDSize f -> f a -> Bool) -> (f a -> c) -> String -> (f a -> e) -> c Source #
unary dimension-checking bracket
withDim2 :: (FiniteDim f, FiniteDim g, Show e) => f a -> g b -> (FDSize f -> FDSize g -> f a -> g b -> Bool) -> (f a -> g b -> c) -> String -> (f a -> g b -> e) -> c Source #
binary dimension-checking bracket
HasData : accessing inner data (do not export)
Sparse : sparse datastructures
class (FiniteDim f, HasData f a) => Sparse f a where Source #
spy :: Fractional b => f a -> b Source #
Set : things that behave as sets
Sparse Vector
Functor SpVector Source # | |
Foldable SpVector Source # | |
Set SpVector Source # | |
FiniteDim SpVector Source # | |
Normed SpVector Source # | |
Hilbert SpVector Source # | |
VectorSpace SpVector Source # | |
Additive SpVector Source # | |
Sparse SpVector a Source # | |
HasData SpVector a Source # | |
Eq a => Eq (SpVector a) Source # | |
Show a => Show (SpVector a) Source # | |
(Show a, Num a) => PrintDense (SpVector a) Source # | |
type FDSize SpVector Source # | |
type HDData SpVector a Source # | |
spySV :: Fractional b => SpVector a -> b Source #
SpVector sparsity
Creation
singletonSV :: a -> SpVector a Source #
singleton sparse vector (length 1)
mkSpVector :: (Num a, Eq a) => Int -> IntMap a -> SpVector a Source #
create a sparse vector from an association list while discarding all zero entries
mkSpVectorD :: (Num a, Eq a) => Int -> [a] -> SpVector a Source #
", from logically dense array (consecutive indices)
fromListDenseSV :: Int -> [a] -> SpVector a Source #
Create new sparse vector, assumin 0-based, contiguous indexing
Element insertion
insertSpVector :: Int -> a -> SpVector a -> SpVector a Source #
insert element x
at index i
in a preexisting SpVector
fromList
toList
toDenseListSV :: Num b => SpVector b -> [b] Source #
To dense list (default = 0)
Lookup
lookupDenseSV :: Num a => Key -> SpVector a -> a Source #
lookup an index in a SpVector (returns 0 if lookup fails)
Sub-vectors
Outer vector product
Sparse Matrix
Functor SpMatrix Source # | |
Set SpMatrix Source # | |
FiniteDim SpMatrix Source # | |
Additive SpMatrix Source # | |
Sparse SpMatrix a Source # | |
HasData SpMatrix a Source # | |
Eq a => Eq (SpMatrix a) Source # | |
Show a => Show (SpMatrix a) Source # | |
(Show a, Num a) => PrintDense (SpMatrix a) Source # | |
type FDSize SpMatrix Source # | |
type HDData SpMatrix a Source # | |
maxTup :: Ord t => (t, t) -> (t, t) -> (t, t) Source #
Componentwise tuple operations TODO : use semilattice properties instead
minTup :: Ord t => (t, t) -> (t, t) -> (t, t) Source #
Componentwise tuple operations TODO : use semilattice properties instead
Creation
Diagonal matrix
mkDiagonal :: Int -> [a] -> SpMatrix a Source #
Identity matrix
Super- or sub- diagonal matrix
fromList
fromListSM' :: Foldable t => t (IxRow, IxCol, a) -> SpMatrix a -> SpMatrix a Source #
Add to existing SpMatrix using data from list (row, col, value)
fromListSM :: Foldable t => (Int, Int) -> t (IxRow, IxCol, a) -> SpMatrix a Source #
Create new SpMatrix using data from list (row, col, value)
fromListDenseSM :: Int -> [a] -> SpMatrix a Source #
Create new SpMatrix assuming contiguous, 0-based indexing of elements
toList
toDenseListSM :: Num t => SpMatrix t -> [(IxRow, IxCol, t)] Source #
Populate list with SpMatrix contents and populate missing entries with 0
Element insertion
insertSpMatrix :: IxRow -> IxCol -> a -> SpMatrix a -> SpMatrix a Source #
Insert an element in a preexisting Spmatrix at the specified indices
Lookup
lookupWD_SM :: Num a => SpMatrix a -> (IxRow, IxCol) -> a Source #
Looks up an element in the matrix with a default (if the element is not found, zero is returned)
(@@) :: Num a => SpMatrix a -> (IxRow, IxCol) -> a Source #
Zero-default lookup, infix form
Looks up an element in the matrix with a default (if the element is not found, zero is returned)
Multiply matrix by a scalar
Frobenius norm (sqrt of trace of M^T M)
Predicates
validIxSM :: SpMatrix a -> (Int, Int) -> Bool Source #
Are the supplied indices within matrix bounds?
isSquareSM :: SpMatrix a -> Bool Source #
Is the matrix square?
isDiagonalSM :: SpMatrix a -> Bool Source #
Is the matrix diagonal?
Matrix data and metadata
spySM :: Fractional b => SpMatrix a -> b Source #
Non-zero elements in a row
Bandwidth bounds (min, max)
Sub-matrices
extractSubmatrixSM :: SpMatrix a -> (IxRow, IxCol) -> (IxRow, IxCol) -> SpMatrix a Source #
Extract a submatrix given the specified index bounds
Extract j'th column
Extract i'th row
Matrix stacking
Misc. SpMatrix operations
ifoldlSM :: (Key -> Key -> a -> b -> b) -> b -> SpMatrix a -> b Source #
Indexed left fold over SpMatrix
countSubdiagonalNZSM :: SpMatrix a -> Int Source #
Count sub-diagonal nonzeros
extractDiagonalDSM :: Num a => SpMatrix a -> SpVector a Source #
Extract the diagonal as a SpVector (with default 0)
subdiagIndicesSM :: SpMatrix a -> [(Key, Key)] Source #
Filter the index subset that lies below the diagonal (used in the QR decomposition, for example)
sparsify : remove almost-0 elements (i.e. if |x| < eps)
Value rounding
roundZeroOneSM :: SpMatrix Double -> SpMatrix Double Source #
Round almost-0 and almost-1 to 0 and 1 respectively
Primitive algebra operations
transposeSM :: SpMatrix a -> SpMatrix a Source #
transposeSM, (#^) : Matrix transpose
Matrix action on a vector
vecMat :: Num a => SpVector a -> SpMatrix a -> SpVector a Source #
Vector-on-matrix (FIXME : transposes matrix: more costly than matVec
, I think)
(<#) :: Num a => SpVector a -> SpMatrix a -> SpVector a Source #
Vector-on-matrix (FIXME : transposes matrix: more costly than matVec
, I think)
Matrix-matrix product
Matrix-matrix product, sparsified
matMatSparsified :: SpMatrix Double -> SpMatrix Double -> SpMatrix Double Source #
Removes all elements x
for which `| x | <= eps`)
(#~#) :: SpMatrix Double -> SpMatrix Double -> SpMatrix Double Source #
Removes all elements x
for which `| x | <= eps`)
Sparsified matrix products of two matrices
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)
One eigenvalue and eigenvector (Rayleigh iteration)
rayleighStep :: SpMatrix Double -> (SpVector Double, Double) -> (SpVector Double, Double) Source #
Cubic-order convergence, but it requires a mildly educated guess on the initial eigenpair
eigRayleigh :: Int -> SpMatrix Double -> (SpVector Double, Double) -> (SpVector Double, Double) Source #
Householder vector (G & VL Alg. 5.1.1, function house
)
SVD
Iterative linear solvers
residual :: Num a => SpMatrix a -> SpVector a -> SpVector a -> SpVector a Source #
residual of candidate solution x0
CGS
cgs :: SpMatrix Double -> SpVector Double -> SpVector Double -> SpVector Double -> CGS Source #
iterate solver until convergence or until max # of iterations is reached
BiCSSTAB
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
Linear solver interface
linSolveM :: PrimMonad m => LinSolveMethod -> SpMatrix Double -> SpVector Double -> m (SpVector Double) Source #
Linear solve with _random_ starting vector
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 BiCGSTAB method and by 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 (runs in 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
Rounding operations
almostZero :: Double -> Bool Source #
Rounding rule
withDefault :: (t -> Bool) -> t -> t -> t Source #
with2Defaults :: (t -> Bool) -> (t -> Bool) -> t -> t -> t -> t Source #
roundZeroOne :: Double -> Double Source #
Round to respectively 0 or 1 within some predefined numerical precision eps
Random matrices and vectors
Pretty printing
Pretty printer typeclass
class PrintDense a where Source #
Misc. utilities
denseIxArray :: [b] -> [(Int, b)] Source #
integer-indexed ziplist
foldrMap :: (Foldable t, Functor t) => (a -> b) -> (b -> c -> c) -> c -> t a -> c Source #
foldr over the results of a fmap
foldlStrict :: (a -> b -> a) -> a -> [b] -> a Source #
strict left fold
ifoldr :: Num i => (a -> b -> b) -> b -> (i -> c -> d -> a) -> c -> [d] -> b Source #
indexed right fold