diff options
Diffstat (limited to 'packages/base/src/Internal/Util.hs')
-rw-r--r-- | packages/base/src/Internal/Util.hs | 15 |
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((&&&),(***)) | |||
83 | import Data.Complex | 83 | import Data.Complex |
84 | import Data.Function(on) | 84 | import Data.Function(on) |
85 | import Internal.ST | 85 | import Internal.ST |
86 | import Foreign.Storable | ||
86 | #if MIN_VERSION_base(4,11,0) | 87 | #if MIN_VERSION_base(4,11,0) |
87 | import Prelude hiding ((<>)) | 88 | import Prelude hiding ((<>)) |
88 | #endif | 89 | #endif |
@@ -174,7 +175,7 @@ a & b = vjoin [a,b] | |||
174 | 175 | ||
175 | -} | 176 | -} |
176 | infixl 3 ||| | 177 | infixl 3 ||| |
177 | (|||) :: Element t => Matrix t -> Matrix t -> Matrix t | 178 | (|||) :: Storable t => Matrix t -> Matrix t -> Matrix t |
178 | a ||| b = fromBlocks [[a,b]] | 179 | a ||| 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 |
189 | infixl 2 === | 190 | infixl 2 === |
190 | a === b = fromBlocks [[a],[b]] | 191 | a === b = fromBlocks [[a],[b]] |
191 | 192 | ||
@@ -225,7 +226,7 @@ col = asColumn . fromList | |||
225 | 226 | ||
226 | -} | 227 | -} |
227 | infixl 9 ? | 228 | infixl 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 | -} |
242 | infixl 9 ¿ | 243 | infixl 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) |
332 | norm_Frob :: (Normed (Vector t), Element t) => Matrix t -> R | 333 | norm_Frob :: (Normed (Vector t), Storable t) => Matrix t -> R |
333 | norm_Frob = norm_2 . flatten | 334 | norm_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 | |||
346 | True | 347 | True |
347 | 348 | ||
348 | -} | 349 | -} |
349 | magnit :: (Element t, Normed (Vector t)) => R -> t -> Bool | 350 | magnit :: (Storable t, Normed (Vector t)) => R -> t -> Bool |
350 | magnit e x = norm_1 (fromList [x]) > e | 351 | magnit 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 | ||
418 | instance Element t => Indexable (Matrix t) (Vector t) | 419 | instance 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 |