summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/GSL.hs6
-rw-r--r--lib/GSL/Compat.hs14
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/GSL.hs b/lib/GSL.hs
index bffbb62..49c5406 100644
--- a/lib/GSL.hs
+++ b/lib/GSL.hs
@@ -27,12 +27,13 @@ module GSL.Polynomials,
27module GSL.Minimization, 27module GSL.Minimization,
28module GSL.Matrix, 28module GSL.Matrix,
29module GSL.Compat, 29module GSL.Compat,
30module Data.Packed.Plot 30module Data.Packed.Plot,
31module Complex
31 32
32) where 33) where
33 34
34import Data.Packed.Vector hiding (constant) 35import Data.Packed.Vector hiding (constant)
35import Data.Packed.Matrix 36import Data.Packed.Matrix hiding ((><))
36import Data.Packed.Tensor 37import Data.Packed.Tensor
37import LinearAlgebra.Algorithms hiding (pnorm) 38import LinearAlgebra.Algorithms hiding (pnorm)
38import LAPACK 39import LAPACK
@@ -45,3 +46,4 @@ import GSL.Minimization
45import GSL.Matrix 46import GSL.Matrix
46import GSL.Compat 47import GSL.Compat
47import Data.Packed.Plot 48import Data.Packed.Plot
49import 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
17module GSL.Compat( 17module 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
22import Data.Packed.Internal hiding (dsp) 22import Data.Packed.Internal hiding (dsp)
@@ -435,10 +435,19 @@ a <-> b = joinV a b
435 435
436---------------------------------------------------------- 436----------------------------------------------------------
437 437
438vectorMax :: Vector Double -> Double
438vectorMax = toScalarR Max 439vectorMax = toScalarR Max
439 440
441vectorMin :: Vector Double -> Double
440vectorMin = toScalarR Min 442vectorMin = toScalarR Min
441 443
444vectorMaxIndex :: Vector Double -> Int
445vectorMaxIndex = round . toScalarR MaxIdx
446
447vectorMinIndex :: Vector Double -> Int
448vectorMinIndex = round . toScalarR MinIdx
449
450fromArray2D :: (Field e) => Array (Int, Int) e -> Matrix e
442fromArray2D m = (r><c) (elems m) 451fromArray2D 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
474fromComplex :: Matrix (Complex Double) -> (Matrix Double, Matrix Double)
465fromComplex = fromComplexM 475fromComplex = fromComplexM
466 476
477
478pnorm :: (Normed t1, Num t) => t -> t1 -> Double
467pnorm 0 = LinearAlgebra.Algorithms.pnorm Infinity 479pnorm 0 = LinearAlgebra.Algorithms.pnorm Infinity
468pnorm 1 = LinearAlgebra.Algorithms.pnorm PNorm1 480pnorm 1 = LinearAlgebra.Algorithms.pnorm PNorm1
469pnorm 2 = LinearAlgebra.Algorithms.pnorm PNorm2 \ No newline at end of file 481pnorm 2 = LinearAlgebra.Algorithms.pnorm PNorm2 \ No newline at end of file