diff options
author | Alberto Ruiz <aruiz@um.es> | 2015-05-23 12:09:45 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2015-05-23 12:09:45 +0200 |
commit | 36379e29fe99b033313f42464897c32b9805559d (patch) | |
tree | 034d7fa25b010605fd47c71c21b19e53c0fddc4a /packages/base/src | |
parent | 79fd8424425087ac411f3b916582ceb4ac198142 (diff) |
multiplyI
Diffstat (limited to 'packages/base/src')
-rw-r--r-- | packages/base/src/Data/Packed/Internal/Numeric.hs | 14 | ||||
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/LAPACK.hs | 7 |
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 | |||
50 | import Numeric.Vectorized | 50 | import Numeric.Vectorized |
51 | import Data.Complex | 51 | import Data.Complex |
52 | 52 | ||
53 | import Numeric.LinearAlgebra.LAPACK(multiplyR,multiplyC,multiplyF,multiplyQ) | 53 | import Numeric.LinearAlgebra.LAPACK(multiplyR,multiplyC,multiplyF,multiplyQ,multiplyI) |
54 | import Data.Packed.Internal | 54 | import Data.Packed.Internal |
55 | import Foreign.C.Types(CInt) | 55 | import Foreign.C.Types(CInt) |
56 | import Text.Printf(printf) | 56 | import 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 | ||
575 | instance 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 | |||
575 | emptyMul m a b | 583 | emptyMul 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 | |||
706 | type instance RealOf Float = Float | 714 | type instance RealOf Float = Float |
707 | type instance RealOf (Complex Float) = Float | 715 | type instance RealOf (Complex Float) = Float |
708 | 716 | ||
717 | type instance RealOf CInt = CInt | ||
718 | |||
709 | type family ComplexOf x | 719 | type family ComplexOf x |
710 | 720 | ||
711 | type instance ComplexOf Double = Complex Double | 721 | type 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 | ||
15 | module Numeric.LinearAlgebra.LAPACK ( | 15 | module 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 | |||
58 | foreign import ccall unsafe "multiplyC" zgemmc :: CInt -> CInt -> TCMCMCM | 58 | foreign import ccall unsafe "multiplyC" zgemmc :: CInt -> CInt -> TCMCMCM |
59 | foreign import ccall unsafe "multiplyF" sgemmc :: CInt -> CInt -> TFMFMFM | 59 | foreign import ccall unsafe "multiplyF" sgemmc :: CInt -> CInt -> TFMFMFM |
60 | foreign import ccall unsafe "multiplyQ" cgemmc :: CInt -> CInt -> TQMQMQM | 60 | foreign import ccall unsafe "multiplyQ" cgemmc :: CInt -> CInt -> TQMQMQM |
61 | foreign import ccall unsafe "multiplyI" c_multiplyI :: CInt -> CInt -> (CM CInt (CM CInt (CM CInt (IO CInt)))) | ||
61 | 62 | ||
62 | isT Matrix{order = ColumnMajor} = 0 | 63 | isT Matrix{order = ColumnMajor} = 0 |
63 | isT Matrix{order = RowMajor} = 1 | 64 | isT Matrix{order = RowMajor} = 1 |
@@ -88,6 +89,10 @@ multiplyF a b = multiplyAux sgemmc "sgemmc" a b | |||
88 | multiplyQ :: Matrix (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex Float) | 89 | multiplyQ :: Matrix (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex Float) |
89 | multiplyQ a b = multiplyAux cgemmc "cgemmc" a b | 90 | multiplyQ a b = multiplyAux cgemmc "cgemmc" a b |
90 | 91 | ||
92 | multiplyI :: Matrix CInt -> Matrix CInt -> Matrix CInt | ||
93 | multiplyI = multiplyAux c_multiplyI "c_multiplyI" | ||
94 | |||
95 | |||
91 | ----------------------------------------------------------------------------- | 96 | ----------------------------------------------------------------------------- |
92 | foreign import ccall unsafe "svd_l_R" dgesvd :: TMMVM | 97 | foreign import ccall unsafe "svd_l_R" dgesvd :: TMMVM |
93 | foreign import ccall unsafe "svd_l_C" zgesvd :: TCMCMVCM | 98 | foreign import ccall unsafe "svd_l_C" zgesvd :: TCMCMVCM |