1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
-----------------------------------------------------------------------------
-- |
-- Module : Data.Packed.Vector
-- Copyright : (c) Alberto Ruiz 2007
-- License : GPL-style
--
-- Maintainer : Alberto Ruiz <aruiz@um.es>
-- Stability : provisional
-- Portability : portable
--
-- Vectors
--
-----------------------------------------------------------------------------
module Data.Packed.Vector (
Vector,
fromList, (|>), toList,
dim, (@>),
subVector, join,
constant, linspace,
vectorMax, vectorMin, vectorMaxIndex, vectorMinIndex,
liftVector, liftVector2
) where
import Data.Packed.Internal
import Complex
import GSL.Vector
{- | Creates a real vector containing a range of values:
@\> linspace 5 (-3,7)
5 |> [-3.0,-0.5,2.0,4.5,7.0]@
-}
linspace :: Int -> (Double, Double) -> Vector Double
linspace n (a,b) = fromList [a, a+delta .. b]
where delta = (b-a)/(fromIntegral n -1)
vectorMax :: Vector Double -> Double
vectorMax = toScalarR Max
vectorMin :: Vector Double -> Double
vectorMin = toScalarR Min
vectorMaxIndex :: Vector Double -> Int
vectorMaxIndex = round . toScalarR MaxIdx
vectorMinIndex :: Vector Double -> Int
vectorMinIndex = round . toScalarR MinIdx
|