blas-0.5: Bindings to the BLAS librarySource codeContentsIndex
Data.Vector.Dense
Stabilityexperimental
MaintainerPatrick Perry <patperry@stanford.edu>
Contents
Creating vectors
Special vectors
Augmenting vectors
Norms and dot product
Vector arithmetic
Converting to and from lists
Casting vectors
Unsafe operations
Description
Synopsis
type Vector n e = DVector Imm n e
module BLAS.Vector
module BLAS.Tensor.Base
module BLAS.Tensor.Dense.Immutable
module BLAS.Tensor.Immutable
module BLAS.Tensor.Scalable
vector :: BLAS1 e => Int -> [(Int, e)] -> Vector n e
listVector :: BLAS1 e => Int -> [e] -> Vector n e
basis :: BLAS1 e => Int -> Int -> Vector n e
subvector :: DVector t n e -> Int -> Int -> DVector t m e
subvectorWithStride :: Int -> DVector t n e -> Int -> Int -> DVector t m e
sumAbs :: BLAS1 e => Vector n e -> Double
norm2 :: BLAS1 e => Vector n e -> Double
whichMaxAbs :: BLAS1 e => Vector n e -> (Int, e)
(<.>) :: BLAS1 e => Vector n e -> Vector n e -> e
shift :: BLAS1 e => e -> Vector n e -> Vector n e
scale :: BLAS1 e => e -> Vector n e -> Vector n e
invScale :: BLAS1 e => e -> Vector n e -> Vector n e
toList :: BLAS1 e => Vector n e -> [e]
fromList :: BLAS1 e => [e] -> Vector n e
coerceVector :: DVector t n e -> DVector t m e
unsafeVector :: BLAS1 e => Int -> [(Int, e)] -> Vector n e
unsafeSubvector :: DVector t n e -> Int -> Int -> DVector t m e
unsafeSubvectorWithStride :: Int -> DVector t n e -> Int -> Int -> DVector t m e
Documentation
type Vector n e = DVector Imm n eSource
module BLAS.Vector
module BLAS.Tensor.Base
module BLAS.Tensor.Dense.Immutable
module BLAS.Tensor.Immutable
module BLAS.Tensor.Scalable
Creating vectors
vector :: BLAS1 e => Int -> [(Int, e)] -> Vector n eSource
Create a vector with the given dimension and elements. The elements given in the association list must all have unique indices, otherwise the result is undefined.
listVector :: BLAS1 e => Int -> [e] -> Vector n eSource
Create a vector of the given dimension with elements initialized to the values from the list.
Special vectors
basis :: BLAS1 e => Int -> Int -> Vector n eSource
basis n i creates a vector of dimension n with zeros everywhere but position i, where there is a one.
Augmenting vectors
subvector :: DVector t n e -> Int -> Int -> DVector t m eSource
subvector x o n creates a subvector view of x starting at index o and having length n.
subvectorWithStride :: Int -> DVector t n e -> Int -> Int -> DVector t m eSource
subvectorWithStride s x o n creates a subvector view of x starting at index o, having length n and stride s.
Norms and dot product
sumAbs :: BLAS1 e => Vector n e -> DoubleSource
Compute the sum of absolute values of entries in the vector.
norm2 :: BLAS1 e => Vector n e -> DoubleSource
Compute the 2-norm of a vector.
whichMaxAbs :: BLAS1 e => Vector n e -> (Int, e)Source
Get the index and norm of the element with absulte value. Not valid if any of the vector entries are NaN. Raises an exception if the vector has length 0.
(<.>) :: BLAS1 e => Vector n e -> Vector n e -> eSource
Compute the dot product of two vectors.
Vector arithmetic
shift :: BLAS1 e => e -> Vector n e -> Vector n eSource
Add a value to every element in a vector.
scale :: BLAS1 e => e -> Vector n e -> Vector n eSource
Scale every element by the given value.
invScale :: BLAS1 e => e -> Vector n e -> Vector n eSource
Divide every element by a value.
Converting to and from lists
toList :: BLAS1 e => Vector n e -> [e]Source
Convert a vector to a list. Same as elems.
fromList :: BLAS1 e => [e] -> Vector n eSource
Convert a list to a vector. fromList xs = listVector (length xs) xs.
Casting vectors
coerceVector :: DVector t n e -> DVector t m eSource
Cast the phantom length type.
Unsafe operations
unsafeVector :: BLAS1 e => Int -> [(Int, e)] -> Vector n eSource
Same as vector, but does not range-check the indices.
unsafeSubvector :: DVector t n e -> Int -> Int -> DVector t m eSource
Same as subvector but arguments are not range-checked.
unsafeSubvectorWithStride :: Int -> DVector t n e -> Int -> Int -> DVector t m eSource
Same as subvectorWithStride but arguments are not range-checked.
Produced by Haddock version 2.3.0