blas-0.4.1: Bindings to the BLAS librarySource codeContentsIndex
Data.Vector.Dense.Internal
Stabilityexperimental
MaintainerPatrick Perry <patperry@stanford.edu>
Contents
Vector data types
Conversion to and from ForeignPtrs.
Creating new vectors
Special vectors
Vector views
Casting vectors
Unsafe operations
Description
Synopsis
type Vector n e = DVector Imm n e
type IOVector n e = DVector Mut n e
data DVector t n e
= DV {
fptr :: !(ForeignPtr e)
offset :: !Int
len :: !Int
stride :: !Int
}
| C !(DVector t n e)
module BLAS.Vector
module BLAS.Tensor
fromForeignPtr :: ForeignPtr e -> Int -> Int -> Int -> DVector t n e
toForeignPtr :: DVector t n e -> (ForeignPtr e, Int, Int, Int)
isConj :: Elem e => DVector t n e -> Bool
strideOf :: DVector t n e -> Int
newVector :: BLAS1 e => Int -> [(Int, e)] -> IO (DVector t n e)
newVector_ :: Elem e => Int -> IO (DVector t n e)
newListVector :: Elem e => Int -> [e] -> IO (DVector t n e)
newBasis :: BLAS1 e => Int -> Int -> IO (IOVector n e)
setBasis :: BLAS1 e => Int -> IOVector n e -> IO ()
subvector :: DVector t n e -> Int -> Int -> DVector t m e
subvectorWithStride :: Int -> DVector t n e -> Int -> Int -> DVector t m e
coerceVector :: DVector t n e -> DVector t m e
unsafeNewVector :: BLAS1 e => Int -> [(Int, e)] -> IO (DVector t n e)
unsafeWithElemPtr :: Elem e => DVector t n e -> Int -> (Ptr e -> IO a) -> IO a
unsafeSubvector :: DVector t n e -> Int -> Int -> DVector t m e
unsafeSubvectorWithStride :: Int -> DVector t n e -> Int -> Int -> DVector t m e
unsafeFreeze :: DVector t n e -> Vector n e
unsafeThaw :: DVector t n e -> IOVector n e
Vector data types
type Vector n e = DVector Imm n eSource
type IOVector n e = DVector Mut n eSource
data DVector t n e Source
A dense vector. t is a type that will usually be Imm or Mut. n is a phantom type for the dimension of the vector, and e is the element type. A DVector x stores dim x elements. Indices into the vector are 0-based.
Constructors
DV
fptr :: !(ForeignPtr e)a pointer to the storage region
offset :: !Intan offset (in elements, not bytes) to the first element in the vector.
len :: !Intthe length of the vector
stride :: !Intthe stride (in elements, not bytes) between elements.
C !(DVector t n e)a conjugated vector
show/hide Instances
Vector (DVector t)
BLAS1 e => Scalable (DVector Imm n) e
Tensor (DVector t n) Int e
BLAS1 e => ITensor (DVector Imm n) Int e
BLAS1 e => IDTensor (DVector Imm n) Int e
BLAS1 e => RTensor (DVector t n) Int e IO
BLAS1 e => RDTensor (DVector t n) Int e IO
BLAS1 e => MTensor (DVector Mut n) Int e IO
(BLAS1 e, Eq e) => Eq (DVector Imm n e)
(BLAS2 e, Floating e) => Floating (DVector Imm n e)
BLAS2 e => Fractional (DVector Imm n e)
BLAS2 e => Num (DVector Imm n e)
(BLAS1 e, Show e) => Show (DVector Imm n e)
(BLAS1 e, AEq e) => AEq (DVector Imm n e)
module BLAS.Vector
module BLAS.Tensor
Conversion to and from ForeignPtrs.
fromForeignPtr :: ForeignPtr e -> Int -> Int -> Int -> DVector t n eSource
fromForeignPtr fptr offset n inc creates a vector view of a region in memory starting at the given offset and having dimension n, with a stride of inc.
toForeignPtr :: DVector t n e -> (ForeignPtr e, Int, Int, Int)Source
Gets the tuple (fptr,offset,n,inc), where n is the dimension and inc is the stride of the vector. Note that this does not return the conjugacy information of the vector. For that information, use isConj.
isConj :: Elem e => DVector t n e -> BoolSource
Indicates whether or not the vector has been conjugated. For newly-created vectors, this will be False.
strideOf :: DVector t n e -> IntSource
Gets the stride of the vector.
Creating new vectors
newVector :: BLAS1 e => Int -> [(Int, e)] -> IO (DVector t n e)Source
Creates a new vector with the given association list. Unspecified indices will get initialized to zero.
newVector_ :: Elem e => Int -> IO (DVector t n e)Source
Creates a new vector of the given length. The elements will be uninitialized.
newListVector :: Elem e => Int -> [e] -> IO (DVector t n e)Source
Creates a new vector of the given dimension with the given elements. If the list has length less than the passed-in dimenson, the tail of the vector will be uninitialized.
Special vectors
newBasis :: BLAS1 e => Int -> Int -> IO (IOVector n e)Source
newBasis n i creates a vector of length n that is all zero except for at position i, where it equal to one.
setBasis :: BLAS1 e => Int -> IOVector n e -> IO ()Source
setBasis x i sets the ith coordinate of x to 1, and all other coordinates to 0. If the vector has been scaled, it is possible that readVector x i will not return exactly 1. See setElem.
Vector views
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.
Casting vectors
coerceVector :: DVector t n e -> DVector t m eSource
Cast the phantom length type.
Unsafe operations
unsafeNewVector :: BLAS1 e => Int -> [(Int, e)] -> IO (DVector t n e)Source
Same as newVector but indices are not range-checked.
unsafeWithElemPtr :: Elem e => DVector t n e -> Int -> (Ptr e -> IO a) -> IO aSource
Evaluate a function with a pointer to the value stored at the given index. Note that the value may need to conjugated before using it. See isConj.
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.
unsafeFreeze :: DVector t n e -> Vector n eSource
Cast the access type to Imm.
unsafeThaw :: DVector t n e -> IOVector n eSource
Cast the access type to Mut.
Produced by Haddock version 2.3.0