hmatrix-0.10.0.0: Linear algebra and numerical computation

Portability portable provisional Alberto Ruiz

Data.Packed.Vector

Description

1D arrays suitable for numeric computations using external libraries.

This module provides basic functions for manipulation of structure.

Synopsis

# Documentation

data Vector t Source

One-dimensional array of objects stored in a contiguous memory block.

Instances

 Complexable Vector Joinable Vector Matrix Joinable Matrix Vector Container Vector Double Container Vector Float Normed Vector Double Normed Vector Float Mul Vector Matrix Vector Mul Matrix Vector Vector Container Vector (Complex Double) Container Vector (Complex Float) Normed Vector (Complex Double) Normed Vector (Complex Float) Container Vector a => Eq (Vector a) Floating (Vector Double) Floating (Vector Float) Floating (Vector (Complex Double)) Floating (Vector (Complex Float)) (Container Vector a, Num (Vector a)) => Fractional (Vector a) Num (Vector Double) Num (Vector Float) Num (Vector (Complex Double)) Num (Vector (Complex Float)) (Element a, Read a) => Read (Vector a) (Show a, Storable a) => Show (Vector a) (Field a, Arbitrary a) => Arbitrary (Vector a) (Binary a, Storable a) => Binary (Vector a)

fromList :: Storable a => [a] -> Vector aSource

creates a Vector from a list:

```> fromList [2,3,5,7]
4 |> [2.0,3.0,5.0,7.0]```

(|>) :: Storable a => Int -> [a] -> Vector aSource

An alternative to `fromList` with explicit dimension. The input list is explicitly truncated if it is too long, so it may safely be used, for instance, with infinite lists.

This is the format used in the instances for Show (Vector a).

toList :: Storable a => Vector a -> [a]Source

extracts the Vector elements to a list

```> toList (linspace 5 (1,10))
[1.0,3.25,5.5,7.75,10.0]```

buildVector :: Storable a => Int -> (Int -> a) -> Vector aSource

creates a Vector of the specified length using the supplied function to to map the index to the value at that index.

```> buildVector 4 fromIntegral
4 |> [0.0,1.0,2.0,3.0]```

dim :: Storable t => Vector t -> IntSource

Number of elements

(@>) :: Storable t => Vector t -> Int -> tSource

```> fromList [0..9] @> 7
7.0```

Arguments

 :: Storable t => Int index of the starting element -> Int number of elements to extract -> Vector t source -> Vector t result

takes a number of consecutive elements from a Vector

```> subVector 2 3 (fromList [1..10])
3 |> [3.0,4.0,5.0]```

takesV :: Storable t => [Int] -> Vector t -> [Vector t]Source

Extract consecutive subvectors of the given sizes.

```> takesV [3,4] (linspace 10 (1,10))
[3 |> [1.0,2.0,3.0],4 |> [4.0,5.0,6.0,7.0]]```

join :: Storable t => [Vector t] -> Vector tSource

creates a new Vector by joining a list of Vectors

```> join [fromList [1..5], constant 1 3]
8 |> [1.0,2.0,3.0,4.0,5.0,1.0,1.0,1.0]```

mapVector :: (Storable a, Storable b) => (a -> b) -> Vector a -> Vector bSource

map on Vectors

zipVector :: (Storable a, Storable b, Storable (a, b)) => Vector a -> Vector b -> Vector (a, b)Source

zip for Vectors

zipVectorWith :: (Storable a, Storable b, Storable c) => (a -> b -> c) -> Vector a -> Vector b -> Vector cSource

zipWith for Vectors

unzipVector :: (Storable a, Storable b, Storable (a, b)) => Vector (a, b) -> (Vector a, Vector b)Source

unzip for Vectors

unzipVectorWith :: (Storable (a, b), Storable c, Storable d) => ((a, b) -> (c, d)) -> Vector (a, b) -> (Vector c, Vector d)Source

unzipWith for Vectors

mapVectorM :: (Storable a, Storable b, Monad m) => (a -> m b) -> Vector a -> m (Vector b)Source

monadic map over Vectors the monad `m` must be strict

mapVectorM_ :: (Storable a, Monad m) => (a -> m ()) -> Vector a -> m ()Source

mapVectorWithIndexM :: (Storable a, Storable b, Monad m) => (Int -> a -> m b) -> Vector a -> m (Vector b)Source

monadic map over Vectors with the zero-indexed index passed to the mapping function the monad `m` must be strict

mapVectorWithIndexM_ :: (Storable a, Monad m) => (Int -> a -> m ()) -> Vector a -> m ()Source

monadic map over Vectors with the zero-indexed index passed to the mapping function

foldLoop :: (Int -> t -> t) -> t -> Int -> tSource

foldVector :: Storable a => (a -> b -> b) -> b -> Vector a -> bSource

foldVectorG :: Storable a => (Int -> (Int -> a) -> t -> t) -> t -> Vector a -> tSource

foldVectorWithIndex :: Storable a => (Int -> a -> b -> b) -> b -> Vector a -> bSource