summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-05-25 11:00:20 +0200
committerAlberto Ruiz <aruiz@um.es>2015-05-25 11:00:20 +0200
commitf38aba5c0086e662a9e49043f414d03a0dacb044 (patch)
treefcf8e3b51551f7d64c292e231e2256c51f5c8983
parente803d45acc0fd3202af9ea3844c554a9b807bade (diff)
indexable and normed CInt elements
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Util.hs13
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)
66import Text.Printf 66import Text.Printf
67import Data.List.Split(splitOn) 67import Data.List.Split(splitOn)
68import Data.List(intercalate) 68import Data.List(intercalate)
69import Foreign.C.Types(CInt)
69 70
70type ℝ = Double 71type ℝ = Double
71type ℕ = Int 72type ℕ = 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
274instance 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
274norm_Frob :: (Normed (Vector t), Element t) => Matrix t -> ℝ 283norm_Frob :: (Normed (Vector t), Element t) => Matrix t -> ℝ
275norm_Frob = norm_2 . flatten 284norm_Frob = norm_2 . flatten
@@ -324,6 +333,10 @@ instance Indexable (Vector Float) Float
324 where 333 where
325 (!) = (@>) 334 (!) = (@>)
326 335
336instance Indexable (Vector CInt) CInt
337 where
338 (!) = (@>)
339
327instance Indexable (Vector (Complex Double)) (Complex Double) 340instance Indexable (Vector (Complex Double)) (Complex Double)
328 where 341 where
329 (!) = (@>) 342 (!) = (@>)