diff options
author | Alberto Ruiz <aruiz@um.es> | 2015-05-25 11:00:20 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2015-05-25 11:00:20 +0200 |
commit | f38aba5c0086e662a9e49043f414d03a0dacb044 (patch) | |
tree | fcf8e3b51551f7d64c292e231e2256c51f5c8983 /packages | |
parent | e803d45acc0fd3202af9ea3844c554a9b807bade (diff) |
indexable and normed CInt elements
Diffstat (limited to 'packages')
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/Util.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util.hs b/packages/base/src/Numeric/LinearAlgebra/Util.hs index 370ca27..2e632b7 100644 --- a/packages/base/src/Numeric/LinearAlgebra/Util.hs +++ b/packages/base/src/Numeric/LinearAlgebra/Util.hs | |||
@@ -66,6 +66,7 @@ import Control.Monad(when) | |||
66 | import Text.Printf | 66 | import Text.Printf |
67 | import Data.List.Split(splitOn) | 67 | import Data.List.Split(splitOn) |
68 | import Data.List(intercalate) | 68 | import Data.List(intercalate) |
69 | import Foreign.C.Types(CInt) | ||
69 | 70 | ||
70 | type ℝ = Double | 71 | type ℝ = Double |
71 | type ℕ = Int | 72 | type ℕ = Int |
@@ -270,6 +271,14 @@ instance Normed (Matrix ℂ) | |||
270 | norm_2 = pnorm PNorm2 | 271 | norm_2 = pnorm PNorm2 |
271 | norm_Inf = pnorm Infinity | 272 | norm_Inf = pnorm Infinity |
272 | 273 | ||
274 | instance Normed (Vector CInt) | ||
275 | where | ||
276 | norm_0 = fromIntegral . sumElements . step . abs | ||
277 | norm_1 = fromIntegral . norm1 | ||
278 | norm_2 v = sqrt . fromIntegral $ dot v v | ||
279 | norm_Inf = fromIntegral . normInf | ||
280 | |||
281 | |||
273 | 282 | ||
274 | norm_Frob :: (Normed (Vector t), Element t) => Matrix t -> ℝ | 283 | norm_Frob :: (Normed (Vector t), Element t) => Matrix t -> ℝ |
275 | norm_Frob = norm_2 . flatten | 284 | norm_Frob = norm_2 . flatten |
@@ -324,6 +333,10 @@ instance Indexable (Vector Float) Float | |||
324 | where | 333 | where |
325 | (!) = (@>) | 334 | (!) = (@>) |
326 | 335 | ||
336 | instance Indexable (Vector CInt) CInt | ||
337 | where | ||
338 | (!) = (@>) | ||
339 | |||
327 | instance Indexable (Vector (Complex Double)) (Complex Double) | 340 | instance Indexable (Vector (Complex Double)) (Complex Double) |
328 | where | 341 | where |
329 | (!) = (@>) | 342 | (!) = (@>) |