|
Module VectorThis module is undocumented. This is a list of its definitions. (**) :: Ring a => VecComp a => a -> Vector a -> Vector a
The scalar goes on the left only. There is no right-hand variant, so
Example:
Ring_Vector_a_super0 :: VecComp a => Ring a => Additive (Vector a) allVector :: (a -> <b> Boolean) -> Vector a -> <b> Boolean Returns anyVector :: (a -> <b> Boolean) -> Vector a -> <b> Boolean Returns concatVector :: Vector a -> Vector a -> Vector a Creates a vector containing the elements of the first vector followed by the elements of the second one. containsVector :: a -> Vector a -> Boolean
Mind the argument order: the element comes first and the vector second,
which is the opposite way round from every other It also does not short-circuit. It folds over every index of the vector and
combines the comparisons with Example:
copyFromMVector :: MVector a -> Integer -> MVector a -> Integer -> Integer -> <Proc> ()
Example:
copyFromVector :: Vector a -> Integer -> MVector a -> Integer -> Integer -> <Proc> ()
Four of the five arguments are indices or lengths, so the order is worth
reading carefully: source, offset in the source, target, offset in the
target, number of elements. The elements of Example:
dotp :: Ring a => VecComp a => Vector a -> Vector a -> a The dot product of the two vectors: the sum of the products of their corresponding elements. Only the leading elements up to the length of the shorter vector are used, so the tail of the longer one is discarded. The operations of this module that combine two vectors each treat unequal lengths differently, and only the last of them reports an error:
Examples:
foldlVector :: (a -> b -> <c> a) -> a -> Vector b -> <c> a Folds over all elements of the vector starting with the given initial value. iterVector :: (a -> <c> b) -> Vector a -> <c> () Calls the given function with all elements of the vector. l1Norm :: OrderedRing a => IndexedSequence b => Sequence (b a) => b a -> a The 1-norm of the vector, i.e. the sum of the absolute values of its elements. mapFirstVector :: (a -> <c> Maybe b) -> Vector a -> <c> Maybe b Applies the given function to the elements of the vector until it returns
Here "first" genuinely means first: a vector has a defined order, so the scan
runs from index Example:
mapVector :: VecComp a => VecComp b => (a -> b) -> Vector a -> Vector b Creates a vector containing the elements of the given vector mapped with the given function. maxNorm :: OrderedRing a => Sequence (b a) => IndexedSequence b => b a -> a The maximum norm of the vector, i.e. the greatest absolute value of its elements. mvector :: VecComp a => [a] -> <Proc> MVector a Creates a new mutable vector containing the elements of the given list. The result is a fresh vector; later changes to it are not visible in the list. Example:
norm :: Sequence (a b) => IndexedSequence a => Real b => a b -> b The Euclidean norm of the vector. normSq :: IndexedSequence a => Ring b => Sequence (a b) => a b -> b The sum of the squares of the elements of the vector, i.e. the square of its Euclidean norm. singletonVector :: VecComp a => a -> Vector a Creates a vector containing just the given element. sortMVectorByte :: MVector Byte -> <Proc> () Sorts the given mutable vector of bytes into ascending order in place. See sortMVectorCharacter :: MVector Character -> <Proc> () Sorts the given mutable vector of characters into ascending order in place. See sortMVectorDouble :: MVector Double -> <Proc> () Sorts the given mutable vector of doubles into ascending order in place. See sortMVectorFloat :: MVector Float -> <Proc> () Sorts the given mutable vector of floats into ascending order in place. See sortMVectorInt :: MVector Integer -> <Proc> () Sorts the given mutable vector of integers into ascending order in place
and returns There is one of these per primitive element type: Example:
sortMVectorLong :: MVector Long -> <Proc> () Sorts the given mutable vector of longs into ascending order in place. See sortMVectorShort :: MVector Short -> <Proc> () Sorts the given mutable vector of shorts into ascending order in place. See vector :: VecComp a => [a] -> Vector a Creates a vector containing the elements of the given list. A vector prints as the word Example:
vectorF :: VecComp a => Integer -> (Integer -> <b> a) -> <b> Vector a
The length comes first and the generator function second. The indices are
0-based and the upper bound is exclusive, so Example:
vectorToList :: Vector a -> [a] The elements of the vector as a list. zipVectorsWith :: VecComp a => VecComp b => VecComp c => (a -> b -> c) -> Vector a -> Vector b -> Vector c Creates a vector whose element at index The length of the result is the length of the first vector, and the second
vector is read at those same indices. A second vector that is longer is
therefore silently truncated, and a second vector that is shorter is an
error: the read runs off its end and raises This is a third, different rule from the other two ways this module treats
vectors of unequal length. Example:
|