hmatrix-0.1.0.0: Linear algebra and numerical computationsSource codeContentsIndex
Data.Packed.Internal.Vector
Portabilityportable (uses FFI)
Stabilityprovisional
MaintainerAlberto Ruiz <aruiz@um.es>
Description
Vector implementation
Synopsis
data Vector t = V {
dim :: Int
fptr :: ForeignPtr t
}
type Vc t s = Int -> Ptr t -> s
createVector :: Storable a => Int -> IO (Vector a)
fromList :: Storable a => [a] -> Vector a
toList :: Storable a => Vector a -> [a]
(|>) :: Storable a => Int -> [a] -> Vector a
at' :: Storable a => Vector a -> Int -> a
at :: Storable a => Vector a -> Int -> a
subVector :: Storable t => Int -> Int -> Vector t -> Vector t
(@>) :: Storable t => Vector t -> Int -> t
join :: Storable t => [Vector t] -> Vector t
asReal :: Vector (Complex Double) -> Vector Double
asComplex :: Vector Double -> Vector (Complex Double)
liftVector :: (Storable a, Storable b) => (a -> b) -> Vector a -> Vector b
liftVector2 :: (Storable a, Storable b, Storable c) => (a -> b -> c) -> Vector a -> Vector b -> Vector c
Documentation
data Vector t Source
A one-dimensional array of objects stored in a contiguous memory block.
Constructors
V
dim :: Intnumber of elements
fptr :: ForeignPtr tforeign pointer to the memory block
show/hide Instances
type Vc t s = Int -> Ptr t -> sSource
signature of foreign functions admitting C-style vectors
createVector :: Storable a => Int -> IO (Vector a)Source
allocates memory for a new vector
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]
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]
(|>) :: Storable a => Int -> [a] -> Vector aSource
an alternative to fromList with explicit dimension, used also in the instances for Show (Vector a).
at' :: Storable a => Vector a -> Int -> aSource
access to Vector elements without range checking
at :: Storable a => Vector a -> Int -> aSource
access to Vector elements with range checking.
subVectorSource
:: Storable t
=> Intindex of the starting element
-> Intnumber of elements to extract
-> Vector tsource
-> Vector tresult

takes a number of consecutive elements from a Vector

> subVector 2 3 (fromList [1..10])
3 |> [3.0,4.0,5.0]
(@>) :: Storable t => Vector t -> Int -> tSource

Reads a vector position:

> fromList [0..9] @> 7
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]
asReal :: Vector (Complex Double) -> Vector DoubleSource
transforms a complex vector into a real vector with alternating real and imaginary parts
asComplex :: Vector Double -> Vector (Complex Double)Source
transforms a real vector into a complex vector with alternating real and imaginary parts
liftVector :: (Storable a, Storable b) => (a -> b) -> Vector a -> Vector bSource
map on Vectors
liftVector2 :: (Storable a, Storable b, Storable c) => (a -> b -> c) -> Vector a -> Vector b -> Vector cSource
zipWith for Vectors
Produced by Haddock version 2.4.2