summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric/Vector.hs
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/Numeric/Vector.hs')
-rw-r--r--packages/base/src/Numeric/Vector.hs14
1 files changed, 12 insertions, 2 deletions
diff --git a/packages/base/src/Numeric/Vector.hs b/packages/base/src/Numeric/Vector.hs
index 017196c..1e5877d 100644
--- a/packages/base/src/Numeric/Vector.hs
+++ b/packages/base/src/Numeric/Vector.hs
@@ -3,6 +3,9 @@
3{-# LANGUAGE FlexibleInstances #-} 3{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE UndecidableInstances #-} 4{-# LANGUAGE UndecidableInstances #-}
5{-# LANGUAGE MultiParamTypeClasses #-} 5{-# LANGUAGE MultiParamTypeClasses #-}
6
7{-# OPTIONS_GHC -fno-warn-orphans #-}
8
6----------------------------------------------------------------------------- 9-----------------------------------------------------------------------------
7-- | 10-- |
8-- Module : Numeric.Vector 11-- Module : Numeric.Vector
@@ -14,7 +17,7 @@
14-- 17--
15-- Provides instances of standard classes 'Show', 'Read', 'Eq', 18-- Provides instances of standard classes 'Show', 'Read', 'Eq',
16-- 'Num', 'Fractional', and 'Floating' for 'Vector'. 19-- 'Num', 'Fractional', and 'Floating' for 'Vector'.
17-- 20--
18----------------------------------------------------------------------------- 21-----------------------------------------------------------------------------
19 22
20module Numeric.Vector () where 23module Numeric.Vector () where
@@ -23,9 +26,17 @@ import Internal.Vectorized
23import Internal.Vector 26import Internal.Vector
24import Internal.Numeric 27import Internal.Numeric
25import Internal.Conversion 28import Internal.Conversion
29import Foreign.Storable(Storable)
26 30
27------------------------------------------------------------------- 31-------------------------------------------------------------------
28 32
33adaptScalar :: (Foreign.Storable.Storable t1, Foreign.Storable.Storable t2)
34 => (t1 -> Vector t2 -> t)
35 -> (Vector t1 -> Vector t2 -> t)
36 -> (Vector t1 -> t2 -> t)
37 -> Vector t1
38 -> Vector t2
39 -> t
29adaptScalar f1 f2 f3 x y 40adaptScalar f1 f2 f3 x y
30 | dim x == 1 = f1 (x@>0) y 41 | dim x == 1 = f1 (x@>0) y
31 | dim y == 1 = f3 x (y@>0) 42 | dim y == 1 = f3 x (y@>0)
@@ -172,4 +183,3 @@ instance Floating (Vector (Complex Float)) where
172 sqrt = vectorMapQ Sqrt 183 sqrt = vectorMapQ Sqrt
173 (**) = adaptScalar (vectorMapValQ PowSV) (vectorZipQ Pow) (flip (vectorMapValQ PowVS)) 184 (**) = adaptScalar (vectorMapValQ PowSV) (vectorZipQ Pow) (flip (vectorMapValQ PowVS))
174 pi = fromList [pi] 185 pi = fromList [pi]
175