linear-massiv 0.1.0.0 → 0.1.0.1
raw patch · 20 files changed
+73/−137 lines, 20 filesdep ~ghc-prim
Dependency ranges changed: ghc-prim
Files
- linear-massiv.cabal +5/−2
- src/Numeric/LinearAlgebra/Massiv/BLAS/Level2.hs +2/−3
- src/Numeric/LinearAlgebra/Massiv/BLAS/Level3.hs +2/−2
- src/Numeric/LinearAlgebra/Massiv/Eigen/Hessenberg.hs +0/−1
- src/Numeric/LinearAlgebra/Massiv/Eigen/Power.hs +1/−3
- src/Numeric/LinearAlgebra/Massiv/Eigen/Schur.hs +21/−27
- src/Numeric/LinearAlgebra/Massiv/Eigen/Symmetric.hs +1/−46
- src/Numeric/LinearAlgebra/Massiv/Internal.hs +2/−2
- src/Numeric/LinearAlgebra/Massiv/Internal/Kernel.hs +32/−34
- src/Numeric/LinearAlgebra/Massiv/Linear.hs +0/−1
- src/Numeric/LinearAlgebra/Massiv/Norms.hs +0/−1
- src/Numeric/LinearAlgebra/Massiv/Orthogonal/Givens.hs +0/−1
- src/Numeric/LinearAlgebra/Massiv/Orthogonal/Householder.hs +0/−2
- src/Numeric/LinearAlgebra/Massiv/Orthogonal/LeastSquares.hs +1/−4
- src/Numeric/LinearAlgebra/Massiv/Orthogonal/QR.hs +2/−2
- src/Numeric/LinearAlgebra/Massiv/Solve/Banded.hs +1/−1
- src/Numeric/LinearAlgebra/Massiv/Solve/Cholesky.hs +1/−2
- src/Numeric/LinearAlgebra/Massiv/Solve/LU.hs +1/−1
- src/Numeric/LinearAlgebra/Massiv/Solve/Triangular.hs +0/−1
- src/Numeric/LinearAlgebra/Massiv/Types.hs +1/−1
linear-massiv.cabal view
@@ -1,6 +1,9 @@ cabal-version: 3.0 name: linear-massiv-version: 0.1.0.0+category: Math, Algebra, Numerical+version: 0.1.0.1+author: Nadia Chambers+maintainer: Nadia Yvette Chambers <nadia.yvette.chambers@gmail.com> synopsis: Type-safe numerical linear algebra backed by massiv arrays description: Native Haskell implementations of algorithms from Golub & Van Loan's@@ -42,7 +45,7 @@ Numeric.LinearAlgebra.Massiv.Linear build-depends: base >= 4.16 && < 5,- ghc-prim,+ ghc-prim < 1.0.0, massiv >= 1.0 && < 2, linear >= 1.21 && < 2, vector >= 0.12 && < 1,
src/Numeric/LinearAlgebra/Massiv/BLAS/Level2.hs view
@@ -53,7 +53,7 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix2(..), Sz(..), Comp(..), unwrapByteArray, unwrapByteArrayOffset,+import Data.Massiv.Array (unwrapByteArray, unwrapByteArrayOffset, unwrapMutableByteArray, unwrapMutableByteArrayOffset) import GHC.TypeNats (KnownNat) @@ -92,8 +92,7 @@ gemv :: forall m n r e. (KnownNat m, KnownNat n, M.Manifest r e, Num e) => e -> Matrix m n r e -> Vector n r e -> e -> Vector m r e -> Vector m r e gemv alpha mat x beta y =- let r = dimVal @m- c = dimVal @n+ let c = dimVal @n in makeVector @m @r $ \i -> let axi = foldl (\acc j -> acc + (mat ! (i, j)) * (x !. j)) 0 [0..c-1] in alpha * axi + beta * (y !. i)
src/Numeric/LinearAlgebra/Massiv/BLAS/Level3.hs view
@@ -70,11 +70,11 @@ import Data.Massiv.Array (Ix2(..), Sz(..), Comp(..), unwrapByteArray, unwrapByteArrayOffset, unwrapMutableByteArray, unwrapMutableByteArrayOffset) import GHC.TypeNats (KnownNat)-import GHC.Exts (Int(..), isTrue#, (>=#), (*#), (+#))+import GHC.Exts (Int(..), isTrue#) import GHC.Prim import GHC.ST (ST(..)) import Data.Array.Byte (MutableByteArray(..))-import Data.Primitive.ByteArray (ByteArray(..), newByteArray, unsafeFreezeByteArray)+import Data.Primitive.ByteArray (ByteArray(..)) import Numeric.LinearAlgebra.Massiv.Types import Numeric.LinearAlgebra.Massiv.Internal import Control.Concurrent (forkOn, newEmptyMVar, putMVar, takeMVar, getNumCapabilities)
src/Numeric/LinearAlgebra/Massiv/Eigen/Hessenberg.hs view
@@ -37,7 +37,6 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix1, Ix2(..), Sz(..)) import GHC.TypeNats (KnownNat) import Numeric.LinearAlgebra.Massiv.Types
src/Numeric/LinearAlgebra/Massiv/Eigen/Power.hs view
@@ -40,7 +40,6 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix2(..), Sz(..)) import GHC.TypeNats (KnownNat) import Numeric.LinearAlgebra.Massiv.Types@@ -170,8 +169,7 @@ go iter q lambda | iter >= maxIter = (lambda, q) | otherwise =- let nn = dimVal @n- aShifted = makeMatrix @n @n @r $ \i j ->+ let aShifted = makeMatrix @n @n @r $ \i j -> if i == j then (a ! (i, j)) - lambda else a ! (i, j) z = luSolve aShifted q znorm = nrm2 z
src/Numeric/LinearAlgebra/Massiv/Eigen/Schur.hs view
@@ -45,7 +45,6 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix2(..), Sz(..)) import GHC.TypeNats (KnownNat) import Numeric.LinearAlgebra.Massiv.Types@@ -147,8 +146,7 @@ => Matrix n n r e -> Matrix n n r e -> e -> Int -> (Matrix n n r e, Matrix n n r e) qrStepGivens q h shift p =- let nn = dimVal @n- -- Apply shift: H ← H - σI+ let -- Apply shift: H ← H - σI h_shifted = makeMatrix @n @n @r $ \i j -> if i == j then (h ! (i, j)) - shift else h ! (i, j) -- QR factorization via Givens rotations (only on the active part)@@ -165,7 +163,6 @@ => Matrix n n r e -> Int -> ([(e, e, Int)], Matrix n n r e) applyGivensQR h p = foldl step ([], h) [0..p-1] where- nn = dimVal @n step (rots, hh) k = let (c, s) = givensRotation (hh ! (k, k)) (hh ! (k+1, k)) hh' = applyGivensLeftSq c s k (k+1) hh@@ -234,26 +231,23 @@ -- See GVL4 Section 7.5 for the definition of the real Schur form. eigenvalues :: forall n r e. (KnownNat n, M.Manifest r e, Floating e, Ord e) => Matrix n n r e -> [e]-eigenvalues t =- let nn = dimVal @n- in go 0- where- nn = dimVal @n- go i- | i >= nn = []- | i == nn - 1 = [t ! (i, i)] -- Last 1×1 block- | abs (t ! (i+1, i)) < 1e-12 * (abs (t ! (i, i)) + abs (t ! (i+1, i+1))) =- -- 1×1 block- t ! (i, i) : go (i + 1)- | otherwise =- -- 2×2 block: eigenvalues of [[a,b],[c,d]]- let a = t ! (i, i)- b = t ! (i, i+1)- c = t ! (i+1, i)- d = t ! (i+1, i+1)- tr = a + d- det_ = a * d - b * c- disc = tr * tr / 4 - det_- in if disc >= 0- then (tr / 2 + sqrt disc) : (tr / 2 - sqrt disc) : go (i + 2)- else tr / 2 : tr / 2 : go (i + 2) -- Complex pair, return real parts+eigenvalues t = go 0 where+ nn = dimVal @n+ go i+ | i >= nn = []+ | i == nn - 1 = [t ! (i, i)] -- Last 1×1 block+ | abs (t ! (i+1, i)) < 1e-12 * (abs (t ! (i, i)) + abs (t ! (i+1, i+1))) =+ -- 1×1 block+ t ! (i, i) : go (i + 1)+ | otherwise =+ -- 2×2 block: eigenvalues of [[a,b],[c,d]]+ let a = t ! (i, i)+ b = t ! (i, i+1)+ c = t ! (i+1, i)+ d = t ! (i+1, i+1)+ tr = a + d+ det_ = a * d - b * c+ disc = tr * tr / 4 - det_+ in if disc >= 0+ then (tr / 2 + sqrt disc) : (tr / 2 - sqrt disc) : go (i + 2)+ else tr / 2 : tr / 2 : go (i + 2) -- Complex pair, return real parts
src/Numeric/LinearAlgebra/Massiv/Eigen/Symmetric.hs view
@@ -787,51 +787,6 @@ in (dArr, MkMatrix qArr) {-# NOINLINE symmetricEigenPDC #-} --- | Parallel QR loop: forks independent sub-problems when a split is found.--- Operates in IO to enable forkIO for non-overlapping sub-problem ranges.-rawTridiagQRLoopPar :: MutableByteArray RealWorld -> Int- -> MutableByteArray RealWorld -> Int- -> MutableByteArray RealWorld -> Int- -> Int -> Int -> Double -> IO ()-rawTridiagQRLoopPar mbaD offD mbaSD offSD mbaQ offQ nn maxIter tol = go 0 0 (nn - 1)- where- rd mba off i = stToIO (readRawD mba off i)- wr mba off i v = stToIO (writeRawD mba off i v)-- go !iter !lo !hi- | iter >= maxIter = pure ()- | lo >= hi = pure ()- | otherwise = do- sdhi <- rd mbaSD offSD (hi - 1)- dhi1 <- rd mbaD offD (hi - 1)- dhi <- rd mbaD offD hi- if abs sdhi <= tol * (abs dhi1 + abs dhi)- then do wr mbaSD offSD (hi - 1) 0; go iter lo (hi - 1)- else do- sdlo <- rd mbaSD offSD lo- dlo <- rd mbaD offD lo- dlo1 <- rd mbaD offD (lo + 1)- if abs sdlo <= tol * (abs dlo + abs dlo1)- then do wr mbaSD offSD lo 0; go iter (lo + 1) hi- else do- split <- stToIO $ rawFindSplit mbaD offD mbaSD offSD lo hi tol- case split of- Just q -> do- wr mbaSD offSD q 0- done <- newEmptyMVar- _ <- forkIO $ do- go iter lo q- putMVar done ()- go iter (q + 1) hi- takeMVar done- Nothing -> do- let sp1 = sdhi- delta = (dhi1 - dhi) / 2- sgn = if delta >= 0 then 1 else -1- shift = dhi - sp1*sp1 / (delta + sgn * sqrt (delta*delta + sp1*sp1))- stToIO $ rawImplicitQRStep mbaD offD mbaSD offSD mbaQ offQ nn shift lo hi- go (iter + 1) lo hi- -- | Parallel QR loop with column-major Q for SIMD Givens. rawTridiagQRLoopParCM :: MutableByteArray RealWorld -> Int -> MutableByteArray RealWorld -> Int@@ -1500,7 +1455,7 @@ !mid = dj + gap * 0.5 lam0 <- fixedWeightLoop 0 mid dj dj1 dj dj1 gap zj2 (zj1 * zj1) -- Polish with Newton iterations for higher accuracy- newtonPolish 0 lam0 dj dj1+ newtonPolish (0::Int) lam0 dj dj1 else do -- Last root when rho > 0: between d[n-1] and d[n-1] + rho*||z||² zn2 <- sumZSq mbaZ offZ nn
src/Numeric/LinearAlgebra/Massiv/Internal.hs view
@@ -63,9 +63,9 @@ , zeroVector ) where -import Data.Massiv.Array (Array, Ix2(..), Sz(..), Ix1, Comp(..), D)+import Data.Massiv.Array (Array, Ix2(..), Ix1, Comp(..), D) import qualified Data.Massiv.Array as M-import GHC.TypeNats (Nat, KnownNat, natVal, SomeNat(..), someNatVal)+import GHC.TypeNats (KnownNat, natVal, SomeNat(..), someNatVal) import Data.Proxy (Proxy(..)) import Control.Monad.ST (ST)
src/Numeric/LinearAlgebra/Massiv/Internal/Kernel.hs view
@@ -73,7 +73,6 @@ import GHC.Exts import GHC.Prim import GHC.ST (ST(..))-import GHC.Types (Double(..), Int(..)) import Data.Primitive.ByteArray (ByteArray(..), MutableByteArray(..)) -- --------------------------------------------------------------------------@@ -287,8 +286,8 @@ !cOff1 = off_c +# (i +# 1#) *# n +# j !cOff2 = off_c +# (i +# 2#) *# n +# j !cOff3 = off_c +# (i +# 3#) *# n +# j- in case readDoubleArrayAsDoubleX4# mba_c cOff0 s of { (# s0, c0 #) ->- case readDoubleArrayAsDoubleX4# mba_c cOff1 s0 of { (# s1, c1 #) ->+ in case readDoubleArrayAsDoubleX4# mba_c cOff0 s of { (# s0', c0 #) ->+ case readDoubleArrayAsDoubleX4# mba_c cOff1 s0' of { (# s1, c1 #) -> case readDoubleArrayAsDoubleX4# mba_c cOff2 s1 of { (# s2, c2 #) -> case readDoubleArrayAsDoubleX4# mba_c cOff3 s2 of { (# s3, c3 #) -> case goK4x4 i j bk kEnd c0 c1 c2 c3 of@@ -334,8 +333,8 @@ !cOff3 = off_c +# (i +# 3#) *# n +# j in case (# goK_s4 bk 0.0## 0.0## 0.0## 0.0## #) of (# (# d0, d1, d2, d3 #) #) ->- case readDoubleArray# mba_c cOff0 s of { (# s0, v0 #) ->- case writeDoubleArray# mba_c cOff0 (v0 +## d0) s0 of { s1 ->+ case readDoubleArray# mba_c cOff0 s of { (# s0', v0 #) ->+ case writeDoubleArray# mba_c cOff0 (v0 +## d0) s0' of { s1 -> case readDoubleArray# mba_c cOff1 s1 of { (# s2, v1 #) -> case writeDoubleArray# mba_c cOff1 (v1 +## d1) s2 of { s3 -> case readDoubleArray# mba_c cOff2 s3 of { (# s4, v2 #) ->@@ -350,8 +349,8 @@ | isTrue# (j >=# j8End) = s | otherwise = let !cOff = off_c +# i *# n +# j- in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0, c0 #) ->- case readDoubleArrayAsDoubleX4# mba_c (cOff +# 4#) s0 of { (# s1, c1 #) ->+ in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0', c0 #) ->+ case readDoubleArrayAsDoubleX4# mba_c (cOff +# 4#) s0' of { (# s1, c1 #) -> case goK1x8 i j bk kEnd c0 c1 of (# r0, r1 #) -> case writeDoubleArrayAsDoubleX4# mba_c cOff r0 s1 of { sw0 ->@@ -375,9 +374,9 @@ | isTrue# (j >=# j4End) = s | otherwise = let !cOff = off_c +# i *# n +# j- in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0, c0 #) ->+ in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0', c0 #) -> case goK1x4 i j bk kEnd c0 of { r0 ->- case writeDoubleArrayAsDoubleX4# mba_c cOff r0 s0 of { s1 ->+ case writeDoubleArrayAsDoubleX4# mba_c cOff r0 s0' of { s1 -> goJ4_1x4 i bk kEnd (j +# 4#) j4End s1 }}} @@ -421,7 +420,6 @@ !j8End = nPanels *# 8# !j4End = n -# (n `remInt#` 4#) -- Packed buffer: nPanels * bs * 8 doubles (each panel: kc × 8)- !packDoubles = nPanels *# bs *# 8# -- Fallback unpacked path (when j8End == 0, i.e. n < 8) goBI_unpacked bi s@@ -462,8 +460,8 @@ !cOff1 = off_c +# (i +# 1#) *# n +# j !cOff2 = off_c +# (i +# 2#) *# n +# j !cOff3 = off_c +# (i +# 3#) *# n +# j- in case readDoubleArrayAsDoubleX4# mba_c cOff0 s of { (# s0, c0 #) ->- case readDoubleArrayAsDoubleX4# mba_c cOff1 s0 of { (# s1, c1 #) ->+ in case readDoubleArrayAsDoubleX4# mba_c cOff0 s of { (# s0', c0 #) ->+ case readDoubleArrayAsDoubleX4# mba_c cOff1 s0' of { (# s1, c1 #) -> case readDoubleArrayAsDoubleX4# mba_c cOff2 s1 of { (# s2, c2 #) -> case readDoubleArrayAsDoubleX4# mba_c cOff3 s2 of { (# s3, c3 #) -> case goKUfb4x4 i j bk kEnd c0 c1 c2 c3 of@@ -508,8 +506,8 @@ !cOff3 = off_c +# (i +# 3#) *# n +# j in case (# goKSfb4 bk 0.0## 0.0## 0.0## 0.0## #) of (# (# d0, d1, d2, d3 #) #) ->- case readDoubleArray# mba_c cOff0 s of { (# s0, v0 #) ->- case writeDoubleArray# mba_c cOff0 (v0 +## d0) s0 of { s1 ->+ case readDoubleArray# mba_c cOff0 s of { (# s0', v0 #) ->+ case writeDoubleArray# mba_c cOff0 (v0 +## d0) s0' of { s1 -> case readDoubleArray# mba_c cOff1 s1 of { (# s2, v1 #) -> case writeDoubleArray# mba_c cOff1 (v1 +## d1) s2 of { s3 -> case readDoubleArray# mba_c cOff2 s3 of { (# s4, v2 #) ->@@ -523,9 +521,9 @@ | isTrue# (j >=# j4EndV) = s | otherwise = let !cOff = off_c +# i *# n +# j- in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0, c0 #) ->+ in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0', c0 #) -> case goKUfb1x4 i j bk kEnd c0 of { r0 ->- case writeDoubleArrayAsDoubleX4# mba_c cOff r0 s0 of { s1 ->+ case writeDoubleArrayAsDoubleX4# mba_c cOff r0 s0' of { s1 -> goJ4Ufb1 i bk kEnd (j +# 4#) j4EndV s1 }}} @@ -680,8 +678,8 @@ | otherwise = let !cOff = off_c +# i *# n +# j !panOff = (j `quotInt#` 8#) *# kc *# 8#- in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0, c0 #) ->- case readDoubleArrayAsDoubleX4# mba_c (cOff +# 4#) s0 of { (# s1, c1 #) ->+ in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0', c0 #) ->+ case readDoubleArrayAsDoubleX4# mba_c (cOff +# 4#) s0' of { (# s1, c1 #) -> case goKP1x8 i panOff bk 0# kc ba_bp c0 c1 of (# r0, r1 #) -> case writeDoubleArrayAsDoubleX4# mba_c cOff r0 s1 of { sw0 ->@@ -712,8 +710,8 @@ !cOff1 = off_c +# (i +# 1#) *# n +# j !cOff2 = off_c +# (i +# 2#) *# n +# j !cOff3 = off_c +# (i +# 3#) *# n +# j- in case readDoubleArrayAsDoubleX4# mba_c cOff0 s of { (# s0, c0 #) ->- case readDoubleArrayAsDoubleX4# mba_c cOff1 s0 of { (# s1, c1 #) ->+ in case readDoubleArrayAsDoubleX4# mba_c cOff0 s of { (# s0', c0 #) ->+ case readDoubleArrayAsDoubleX4# mba_c cOff1 s0' of { (# s1, c1 #) -> case readDoubleArrayAsDoubleX4# mba_c cOff2 s1 of { (# s2, c2 #) -> case readDoubleArrayAsDoubleX4# mba_c cOff3 s2 of { (# s3, c3 #) -> case goKU4x4 i j bk kEnd c0 c1 c2 c3 of@@ -759,8 +757,8 @@ !cOff3 = off_c +# (i +# 3#) *# n +# j in case (# goKS4 bk 0.0## 0.0## 0.0## 0.0## #) of (# (# d0, d1, d2, d3 #) #) ->- case readDoubleArray# mba_c cOff0 s of { (# s0, v0 #) ->- case writeDoubleArray# mba_c cOff0 (v0 +## d0) s0 of { s1 ->+ case readDoubleArray# mba_c cOff0 s of { (# s0', v0 #) ->+ case writeDoubleArray# mba_c cOff0 (v0 +## d0) s0' of { s1 -> case readDoubleArray# mba_c cOff1 s1 of { (# s2, v1 #) -> case writeDoubleArray# mba_c cOff1 (v1 +## d1) s2 of { s3 -> case readDoubleArray# mba_c cOff2 s3 of { (# s4, v2 #) ->@@ -775,9 +773,9 @@ | isTrue# (j >=# j4EndV) = s | otherwise = let !cOff = off_c +# i *# n +# j- in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0, c0 #) ->+ in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0', c0 #) -> case goKU1x4 i j bk kEnd c0 of { r0 ->- case writeDoubleArrayAsDoubleX4# mba_c cOff r0 s0 of { s1 ->+ case writeDoubleArrayAsDoubleX4# mba_c cOff r0 s0' of { s1 -> goJ4U1 i bk kEnd (j +# 4#) j4EndV s1 }}} @@ -923,8 +921,8 @@ !cOff1 = off_c +# (i +# 1#) *# n +# j !cOff2 = off_c +# (i +# 2#) *# n +# j !cOff3 = off_c +# (i +# 3#) *# n +# j- in case readDoubleArrayAsDoubleX4# mba_c cOff0 s of { (# s0, c0 #) ->- case readDoubleArrayAsDoubleX4# mba_c cOff1 s0 of { (# s1, c1 #) ->+ in case readDoubleArrayAsDoubleX4# mba_c cOff0 s of { (# s0', c0 #) ->+ case readDoubleArrayAsDoubleX4# mba_c cOff1 s0' of { (# s1, c1 #) -> case readDoubleArrayAsDoubleX4# mba_c cOff2 s1 of { (# s2, c2 #) -> case readDoubleArrayAsDoubleX4# mba_c cOff3 s2 of { (# s3, c3 #) -> case goK4s i j bk kEnd c0 c1 c2 c3 of@@ -972,8 +970,8 @@ !cOff3 = off_c +# (i +# 3#) *# n +# j in case (# goK_s4 bk 0.0## 0.0## 0.0## 0.0## #) of (# (# d0, d1, d2, d3 #) #) ->- case readDoubleArray# mba_c cOff0 s of { (# s0, v0 #) ->- case writeDoubleArray# mba_c cOff0 (v0 +## d0) s0 of { s1 ->+ case readDoubleArray# mba_c cOff0 s of { (# s0', v0 #) ->+ case writeDoubleArray# mba_c cOff0 (v0 +## d0) s0' of { s1 -> case readDoubleArray# mba_c cOff1 s1 of { (# s2, v1 #) -> case writeDoubleArray# mba_c cOff1 (v1 +## d1) s2 of { s3 -> case readDoubleArray# mba_c cOff2 s3 of { (# s4, v2 #) ->@@ -988,8 +986,8 @@ | isTrue# (j >=# j8End) = s | otherwise = let !cOff = off_c +# i *# n +# j- in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0, c0 #) ->- case readDoubleArrayAsDoubleX4# mba_c (cOff +# 4#) s0 of { (# s1, c1 #) ->+ in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0', c0 #) ->+ case readDoubleArrayAsDoubleX4# mba_c (cOff +# 4#) s0' of { (# s1, c1 #) -> case goK8s1 i j bk kEnd c0 c1 of (# r0, r1 #) -> case writeDoubleArrayAsDoubleX4# mba_c cOff r0 s1 of { sw0 ->@@ -1013,9 +1011,9 @@ | isTrue# (j >=# j4End) = s | otherwise = let !cOff = off_c +# i *# n +# j- in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0, c0 #) ->+ in case readDoubleArrayAsDoubleX4# mba_c cOff s of { (# s0', c0 #) -> case goK4s1 i j bk kEnd c0 of { r0 ->- case writeDoubleArrayAsDoubleX4# mba_c cOff r0 s0 of { s1 ->+ case writeDoubleArrayAsDoubleX4# mba_c cOff r0 s0' of { s1 -> goJ4s1 i bk kEnd (j +# 4#) j4End s1 }}} @@ -1051,8 +1049,8 @@ mirrorRow i j s | isTrue# (j >=# i) = s | otherwise =- case readDoubleArray# mba_c (off_c +# i *# n +# j) s of { (# s0, cij #) ->- case writeDoubleArray# mba_c (off_c +# j *# n +# i) cij s0 of { s1 ->+ case readDoubleArray# mba_c (off_c +# i *# n +# j) s of { (# s0', cij #) ->+ case writeDoubleArray# mba_c (off_c +# j *# n +# i) cij s0' of { s1 -> mirrorRow i (j +# 1#) s1 }}
src/Numeric/LinearAlgebra/Massiv/Linear.hs view
@@ -49,7 +49,6 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix1, Ix2(..), Sz(..)) import qualified Data.Vector as BV import GHC.TypeNats (KnownNat, natVal) import Data.Proxy (Proxy(..))
src/Numeric/LinearAlgebra/Massiv/Norms.hs view
@@ -57,7 +57,6 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix2(..), Sz(..)) import GHC.TypeNats (KnownNat) import Numeric.LinearAlgebra.Massiv.Types
src/Numeric/LinearAlgebra/Massiv/Orthogonal/Givens.hs view
@@ -50,7 +50,6 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix2(..), Sz(..)) import GHC.TypeNats (KnownNat) import Numeric.LinearAlgebra.Massiv.Types
src/Numeric/LinearAlgebra/Massiv/Orthogonal/Householder.hs view
@@ -52,7 +52,6 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix1, Ix2(..), Sz(..)) import GHC.TypeNats (KnownNat) import Numeric.LinearAlgebra.Massiv.Types@@ -122,7 +121,6 @@ => Vector m r e -> e -> Matrix m n r e -> Matrix m n r e applyHouseholderLeft v beta a = let mm = dimVal @m- c = dimVal @n in makeMatrix @m @n @r $ \i j -> let -- w = βAᵀv, w(j) = β · Σᵢ v(i)·A(i,j) wj = beta * foldl' (\acc k -> acc + (v !. k) * (a ! (k, j))) 0 [0..mm-1]
src/Numeric/LinearAlgebra/Massiv/Orthogonal/LeastSquares.hs view
@@ -54,7 +54,6 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix2(..), Sz(..)) import GHC.TypeNats (KnownNat) import Numeric.LinearAlgebra.Massiv.Types@@ -92,9 +91,7 @@ leastSquaresQR :: forall m n r e. (KnownNat m, KnownNat n, M.Manifest r e, Floating e, Ord e) => Matrix m n r e -> Vector m r e -> Vector n r e leastSquaresQR a b =- let mm = dimVal @m- nn = dimVal @n- (q, r) = qr a+ let (q, r) = qr a qt = transpose q -- qtb = Qᵀ·b (dimension m) qtb = matvec qt b
src/Numeric/LinearAlgebra/Massiv/Orthogonal/QR.hs view
@@ -62,7 +62,7 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix1, Ix2(..), Sz(..), unwrapByteArray, unwrapByteArrayOffset,+import Data.Massiv.Array (Ix2(..), unwrapByteArray, unwrapByteArrayOffset, unwrapMutableByteArray, unwrapMutableByteArrayOffset) import GHC.TypeNats (KnownNat) import Control.Monad (when)@@ -76,7 +76,7 @@ import Numeric.LinearAlgebra.Massiv.Orthogonal.Givens (givensRotation) import Numeric.LinearAlgebra.Massiv.Internal.Kernel- (rawMutSumSqColumn, rawMutSumProdColumns, rawMutHouseholderApply, rawMutQAccum,+ (rawMutSumSqColumn, rawMutHouseholderApply, rawMutQAccum, rawGemmKernel, rawZeroDoubles, rawNegateDoubles) -- | Full QR factorisation via Householder reflections (GVL4 Algorithm 5.2.1, p. 249).
src/Numeric/LinearAlgebra/Massiv/Solve/Banded.hs view
@@ -61,7 +61,7 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix1, Ix2(..), Sz(..))+import Data.Massiv.Array (Ix2(..)) import GHC.TypeNats (KnownNat) import Numeric.LinearAlgebra.Massiv.Types
src/Numeric/LinearAlgebra/Massiv/Solve/Cholesky.hs view
@@ -63,12 +63,11 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix1, Ix2(..), Sz(..), unwrapByteArray, unwrapByteArrayOffset,+import Data.Massiv.Array (Ix1, Ix2(..), unwrapByteArray, unwrapByteArrayOffset, unwrapMutableByteArray, unwrapMutableByteArrayOffset) import GHC.TypeNats (KnownNat) import Control.Monad (when) import GHC.Exts-import GHC.Prim import GHC.ST (ST(..)) import Data.Primitive.ByteArray (ByteArray(..), MutableByteArray(..), newByteArray, unsafeFreezeByteArray)
src/Numeric/LinearAlgebra/Massiv/Solve/LU.hs view
@@ -66,7 +66,7 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix1, Ix2(..), Sz(..), unwrapByteArray, unwrapByteArrayOffset,+import Data.Massiv.Array (Ix1, Ix2(..), unwrapByteArray, unwrapByteArrayOffset, unwrapMutableByteArray, unwrapMutableByteArrayOffset) import GHC.TypeNats (KnownNat) import Data.Ord (comparing)
src/Numeric/LinearAlgebra/Massiv/Solve/Triangular.hs view
@@ -55,7 +55,6 @@ ) where import qualified Data.Massiv.Array as M-import Data.Massiv.Array (Ix1, Ix2(..), Sz(..)) import GHC.TypeNats (KnownNat) import Numeric.LinearAlgebra.Massiv.Types
src/Numeric/LinearAlgebra/Massiv/Types.hs view
@@ -59,7 +59,7 @@ , type KnownDims ) where -import Data.Massiv.Array (Array, Ix2(..), Sz(..), Ix1, Comp(..))+import Data.Massiv.Array (Array, Ix2(..), Ix1) import qualified Data.Massiv.Array as M import GHC.TypeNats (Nat, KnownNat, natVal, SomeNat(..), someNatVal) import Data.Proxy (Proxy(..))