diff options
-rw-r--r-- | lib/GSL.hs | 6 | ||||
-rw-r--r-- | lib/GSL/Compat.hs | 14 |
2 files changed, 17 insertions, 3 deletions
@@ -27,12 +27,13 @@ module GSL.Polynomials, | |||
27 | module GSL.Minimization, | 27 | module GSL.Minimization, |
28 | module GSL.Matrix, | 28 | module GSL.Matrix, |
29 | module GSL.Compat, | 29 | module GSL.Compat, |
30 | module Data.Packed.Plot | 30 | module Data.Packed.Plot, |
31 | module Complex | ||
31 | 32 | ||
32 | ) where | 33 | ) where |
33 | 34 | ||
34 | import Data.Packed.Vector hiding (constant) | 35 | import Data.Packed.Vector hiding (constant) |
35 | import Data.Packed.Matrix | 36 | import Data.Packed.Matrix hiding ((><)) |
36 | import Data.Packed.Tensor | 37 | import Data.Packed.Tensor |
37 | import LinearAlgebra.Algorithms hiding (pnorm) | 38 | import LinearAlgebra.Algorithms hiding (pnorm) |
38 | import LAPACK | 39 | import LAPACK |
@@ -45,3 +46,4 @@ import GSL.Minimization | |||
45 | import GSL.Matrix | 46 | import GSL.Matrix |
46 | import GSL.Compat | 47 | import GSL.Compat |
47 | import Data.Packed.Plot | 48 | import Data.Packed.Plot |
49 | import Complex | ||
diff --git a/lib/GSL/Compat.hs b/lib/GSL/Compat.hs index 2cae0c4..560a7d8 100644 --- a/lib/GSL/Compat.hs +++ b/lib/GSL/Compat.hs | |||
@@ -16,7 +16,7 @@ Creates reasonable numeric instances for Vectors and Matrices. In the context of | |||
16 | 16 | ||
17 | module GSL.Compat( | 17 | module GSL.Compat( |
18 | Mul,(<>), readMatrix, size, dispR, dispC, format, gmap, Joinable, (<|>),(<->), GSL.Compat.constant, | 18 | Mul,(<>), readMatrix, size, dispR, dispC, format, gmap, Joinable, (<|>),(<->), GSL.Compat.constant, |
19 | vectorMax, vectorMin, fromArray2D, fromComplex, GSL.Compat.pnorm, scale | 19 | vectorMax, vectorMin, vectorMaxIndex, vectorMinIndex, fromArray2D, fromComplex, GSL.Compat.pnorm, scale |
20 | ) where | 20 | ) where |
21 | 21 | ||
22 | import Data.Packed.Internal hiding (dsp) | 22 | import Data.Packed.Internal hiding (dsp) |
@@ -435,10 +435,19 @@ a <-> b = joinV a b | |||
435 | 435 | ||
436 | ---------------------------------------------------------- | 436 | ---------------------------------------------------------- |
437 | 437 | ||
438 | vectorMax :: Vector Double -> Double | ||
438 | vectorMax = toScalarR Max | 439 | vectorMax = toScalarR Max |
439 | 440 | ||
441 | vectorMin :: Vector Double -> Double | ||
440 | vectorMin = toScalarR Min | 442 | vectorMin = toScalarR Min |
441 | 443 | ||
444 | vectorMaxIndex :: Vector Double -> Int | ||
445 | vectorMaxIndex = round . toScalarR MaxIdx | ||
446 | |||
447 | vectorMinIndex :: Vector Double -> Int | ||
448 | vectorMinIndex = round . toScalarR MinIdx | ||
449 | |||
450 | fromArray2D :: (Field e) => Array (Int, Int) e -> Matrix e | ||
442 | fromArray2D m = (r><c) (elems m) | 451 | fromArray2D m = (r><c) (elems m) |
443 | where ((r0,c0),(r1,c1)) = bounds m | 452 | where ((r0,c0),(r1,c1)) = bounds m |
444 | r = r1-r0+1 | 453 | r = r1-r0+1 |
@@ -462,8 +471,11 @@ fromComplexM m = (reshape c a, reshape c b) | |||
462 | where c = cols m | 471 | where c = cols m |
463 | [a,b] = toColumns $ reshape 2 $ asReal $ flatten m | 472 | [a,b] = toColumns $ reshape 2 $ asReal $ flatten m |
464 | 473 | ||
474 | fromComplex :: Matrix (Complex Double) -> (Matrix Double, Matrix Double) | ||
465 | fromComplex = fromComplexM | 475 | fromComplex = fromComplexM |
466 | 476 | ||
477 | |||
478 | pnorm :: (Normed t1, Num t) => t -> t1 -> Double | ||
467 | pnorm 0 = LinearAlgebra.Algorithms.pnorm Infinity | 479 | pnorm 0 = LinearAlgebra.Algorithms.pnorm Infinity |
468 | pnorm 1 = LinearAlgebra.Algorithms.pnorm PNorm1 | 480 | pnorm 1 = LinearAlgebra.Algorithms.pnorm PNorm1 |
469 | pnorm 2 = LinearAlgebra.Algorithms.pnorm PNorm2 \ No newline at end of file | 481 | pnorm 2 = LinearAlgebra.Algorithms.pnorm PNorm2 \ No newline at end of file |