summaryrefslogtreecommitdiff
path: root/packages/base/src/Internal/Util.hs
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/Internal/Util.hs')
-rw-r--r--packages/base/src/Internal/Util.hs15
1 files changed, 8 insertions, 7 deletions
diff --git a/packages/base/src/Internal/Util.hs b/packages/base/src/Internal/Util.hs
index f642e8d..6f3b4c8 100644
--- a/packages/base/src/Internal/Util.hs
+++ b/packages/base/src/Internal/Util.hs
@@ -83,6 +83,7 @@ import Control.Arrow((&&&),(***))
83import Data.Complex 83import Data.Complex
84import Data.Function(on) 84import Data.Function(on)
85import Internal.ST 85import Internal.ST
86import Foreign.Storable
86#if MIN_VERSION_base(4,11,0) 87#if MIN_VERSION_base(4,11,0)
87import Prelude hiding ((<>)) 88import Prelude hiding ((<>))
88#endif 89#endif
@@ -174,7 +175,7 @@ a & b = vjoin [a,b]
174 175
175-} 176-}
176infixl 3 ||| 177infixl 3 |||
177(|||) :: Element t => Matrix t -> Matrix t -> Matrix t 178(|||) :: Storable t => Matrix t -> Matrix t -> Matrix t
178a ||| b = fromBlocks [[a,b]] 179a ||| b = fromBlocks [[a,b]]
179 180
180-- | a synonym for ('|||') (unicode 0x00a6, broken bar) 181-- | a synonym for ('|||') (unicode 0x00a6, broken bar)
@@ -185,7 +186,7 @@ infixl 3 ¦
185 186
186-- | vertical concatenation 187-- | vertical concatenation
187-- 188--
188(===) :: Element t => Matrix t -> Matrix t -> Matrix t 189(===) :: Storable t => Matrix t -> Matrix t -> Matrix t
189infixl 2 === 190infixl 2 ===
190a === b = fromBlocks [[a],[b]] 191a === b = fromBlocks [[a],[b]]
191 192
@@ -225,7 +226,7 @@ col = asColumn . fromList
225 226
226-} 227-}
227infixl 9 ? 228infixl 9 ?
228(?) :: Element t => Matrix t -> [Int] -> Matrix t 229(?) :: Storable t => Matrix t -> [Int] -> Matrix t
229(?) = flip extractRows 230(?) = flip extractRows
230 231
231{- | extract columns 232{- | extract columns
@@ -240,7 +241,7 @@ infixl 9 ?
240 241
241-} 242-}
242infixl 9 ¿ 243infixl 9 ¿
243(¿) :: Element t => Matrix t -> [Int] -> Matrix t 244(¿) :: Storable t => Matrix t -> [Int] -> Matrix t
244(¿)= flip extractColumns 245(¿)= flip extractColumns
245 246
246 247
@@ -329,7 +330,7 @@ instance Normed (Vector (Complex Float))
329 norm_Inf = norm_Inf . double 330 norm_Inf = norm_Inf . double
330 331
331-- | Frobenius norm (Schatten p-norm with p=2) 332-- | Frobenius norm (Schatten p-norm with p=2)
332norm_Frob :: (Normed (Vector t), Element t) => Matrix t -> R 333norm_Frob :: (Normed (Vector t), Storable t) => Matrix t -> R
333norm_Frob = norm_2 . flatten 334norm_Frob = norm_2 . flatten
334 335
335-- | Sum of singular values (Schatten p-norm with p=1) 336-- | Sum of singular values (Schatten p-norm with p=1)
@@ -346,7 +347,7 @@ True
346True 347True
347 348
348-} 349-}
349magnit :: (Element t, Normed (Vector t)) => R -> t -> Bool 350magnit :: (Storable t, Normed (Vector t)) => R -> t -> Bool
350magnit e x = norm_1 (fromList [x]) > e 351magnit e x = norm_1 (fromList [x]) > e
351 352
352 353
@@ -415,7 +416,7 @@ instance Indexable (Vector (Complex Float)) (Complex Float)
415 where 416 where
416 (!) = (@>) 417 (!) = (@>)
417 418
418instance Element t => Indexable (Matrix t) (Vector t) 419instance Storable t => Indexable (Matrix t) (Vector t)
419 where 420 where
420 m!j = subVector (j*c) c (flatten m) 421 m!j = subVector (j*c) c (flatten m)
421 where 422 where