summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/base/src/Data/Packed/Internal/Numeric.hs14
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/LAPACK.hs7
2 files changed, 18 insertions, 3 deletions
diff --git a/packages/base/src/Data/Packed/Internal/Numeric.hs b/packages/base/src/Data/Packed/Internal/Numeric.hs
index 354863f..2e36de2 100644
--- a/packages/base/src/Data/Packed/Internal/Numeric.hs
+++ b/packages/base/src/Data/Packed/Internal/Numeric.hs
@@ -50,7 +50,7 @@ import Data.Packed.Development
50import Numeric.Vectorized 50import Numeric.Vectorized
51import Data.Complex 51import Data.Complex
52 52
53import Numeric.LinearAlgebra.LAPACK(multiplyR,multiplyC,multiplyF,multiplyQ) 53import Numeric.LinearAlgebra.LAPACK(multiplyR,multiplyC,multiplyF,multiplyQ,multiplyI)
54import Data.Packed.Internal 54import Data.Packed.Internal
55import Foreign.C.Types(CInt) 55import Foreign.C.Types(CInt)
56import Text.Printf(printf) 56import Text.Printf(printf)
@@ -540,7 +540,7 @@ class (Num e, Element e) => Product e where
540 -- | sum of absolute value of elements 540 -- | sum of absolute value of elements
541 norm1 :: Vector e -> RealOf e 541 norm1 :: Vector e -> RealOf e
542 -- | euclidean norm 542 -- | euclidean norm
543 norm2 :: Vector e -> RealOf e 543 norm2 :: Floating e => Vector e -> RealOf e
544 -- | element of maximum magnitude 544 -- | element of maximum magnitude
545 normInf :: Vector e -> RealOf e 545 normInf :: Vector e -> RealOf e
546 546
@@ -572,6 +572,14 @@ instance Product (Complex Double) where
572 normInf = emptyVal (maxElement . fst . fromComplex . vectorMapC Abs) 572 normInf = emptyVal (maxElement . fst . fromComplex . vectorMapC Abs)
573 multiply = emptyMul multiplyC 573 multiply = emptyMul multiplyC
574 574
575instance Product CInt where
576 norm2 = undefined
577-- absSum = emptyVal (toScalarF AbsSum)
578-- norm1 = emptyVal (toScalarF AbsSum)
579-- normInf = emptyVal (maxElement . vectorMapF Abs)
580 multiply = emptyMul multiplyI
581
582
575emptyMul m a b 583emptyMul m a b
576 | x1 == 0 && x2 == 0 || r == 0 || c == 0 = konst' 0 (r,c) 584 | x1 == 0 && x2 == 0 || r == 0 || c == 0 = konst' 0 (r,c)
577 | otherwise = m a b 585 | otherwise = m a b
@@ -706,6 +714,8 @@ type instance RealOf (Complex Double) = Double
706type instance RealOf Float = Float 714type instance RealOf Float = Float
707type instance RealOf (Complex Float) = Float 715type instance RealOf (Complex Float) = Float
708 716
717type instance RealOf CInt = CInt
718
709type family ComplexOf x 719type family ComplexOf x
710 720
711type instance ComplexOf Double = Complex Double 721type instance ComplexOf Double = Complex Double
diff --git a/packages/base/src/Numeric/LinearAlgebra/LAPACK.hs b/packages/base/src/Numeric/LinearAlgebra/LAPACK.hs
index d96e14f..219d996 100644
--- a/packages/base/src/Numeric/LinearAlgebra/LAPACK.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/LAPACK.hs
@@ -14,7 +14,7 @@
14 14
15module Numeric.LinearAlgebra.LAPACK ( 15module Numeric.LinearAlgebra.LAPACK (
16 -- * Matrix product 16 -- * Matrix product
17 multiplyR, multiplyC, multiplyF, multiplyQ, 17 multiplyR, multiplyC, multiplyF, multiplyQ, multiplyI,
18 -- * Linear systems 18 -- * Linear systems
19 linearSolveR, linearSolveC, 19 linearSolveR, linearSolveC,
20 mbLinearSolveR, mbLinearSolveC, 20 mbLinearSolveR, mbLinearSolveC,
@@ -58,6 +58,7 @@ foreign import ccall unsafe "multiplyR" dgemmc :: CInt -> CInt -> TMMM
58foreign import ccall unsafe "multiplyC" zgemmc :: CInt -> CInt -> TCMCMCM 58foreign import ccall unsafe "multiplyC" zgemmc :: CInt -> CInt -> TCMCMCM
59foreign import ccall unsafe "multiplyF" sgemmc :: CInt -> CInt -> TFMFMFM 59foreign import ccall unsafe "multiplyF" sgemmc :: CInt -> CInt -> TFMFMFM
60foreign import ccall unsafe "multiplyQ" cgemmc :: CInt -> CInt -> TQMQMQM 60foreign import ccall unsafe "multiplyQ" cgemmc :: CInt -> CInt -> TQMQMQM
61foreign import ccall unsafe "multiplyI" c_multiplyI :: CInt -> CInt -> (CM CInt (CM CInt (CM CInt (IO CInt))))
61 62
62isT Matrix{order = ColumnMajor} = 0 63isT Matrix{order = ColumnMajor} = 0
63isT Matrix{order = RowMajor} = 1 64isT Matrix{order = RowMajor} = 1
@@ -88,6 +89,10 @@ multiplyF a b = multiplyAux sgemmc "sgemmc" a b
88multiplyQ :: Matrix (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex Float) 89multiplyQ :: Matrix (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex Float)
89multiplyQ a b = multiplyAux cgemmc "cgemmc" a b 90multiplyQ a b = multiplyAux cgemmc "cgemmc" a b
90 91
92multiplyI :: Matrix CInt -> Matrix CInt -> Matrix CInt
93multiplyI = multiplyAux c_multiplyI "c_multiplyI"
94
95
91----------------------------------------------------------------------------- 96-----------------------------------------------------------------------------
92foreign import ccall unsafe "svd_l_R" dgesvd :: TMMVM 97foreign import ccall unsafe "svd_l_R" dgesvd :: TMMVM
93foreign import ccall unsafe "svd_l_C" zgesvd :: TCMCMVCM 98foreign import ccall unsafe "svd_l_C" zgesvd :: TCMCMVCM