summaryrefslogtreecommitdiff
path: root/lib/GSL/Compat.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-07-18 07:31:41 +0000
committerAlberto Ruiz <aruiz@um.es>2007-07-18 07:31:41 +0000
commit9d21bf7a1516d8e6a57198ce71c2cc11a8e0520b (patch)
treeb2feed462cc18bb9b81efc7bc6e9f56347411cb2 /lib/GSL/Compat.hs
parent04c76641caa9e1184fe504c584ddeb5420e994d6 (diff)
easyVision compiles ok
Diffstat (limited to 'lib/GSL/Compat.hs')
-rw-r--r--lib/GSL/Compat.hs14
1 files changed, 13 insertions, 1 deletions
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