In case when resulting array representation matches the one of vector's it
will do a O(1) - conversion using castFromVector, otherwise Vector elements
will be copied into a new array. Will throw an error if length of resulting
array doesn't match the source vector length.
O(1) - conversion from vector to an array with a corresponding representation. Will
return Nothing if there is a size mismatch or if some non-standard vector type is
supplied. Is suppplied is the boxed Vector then it's all elements will be
evaluated toWHNF, therefore complexity will be O(n)
Convert an array into a vector. Will perform a cast if resulting vector is
of compatible representation, otherwise memory copy will occur.
Examples
In this example a Storable Array is created and then casted into a Storable
Vector in costant time:
Example4 expressions
>>> import Data.Massiv.Array as A>>> import Data.Massiv.Array.Manifest.Vector (toVector)>>> import qualified Data.Vector.Storable as VS>>> toVector (makeArrayR S Par (Sz2 5 6) (\(i :. j) -> i + j)) :: VS.Vector Int[0,1,2,3,4,5,1,2,3,4,5,6,2,3,4,5,6,7,3,4,5,6,7,8,4,5,6,7,8,9]
While in this example Storable Array will first be converted into Unboxed
representation in Parallel and only after that will be coverted into Unboxed
Vector in constant time.
Example2 expressions
>>> import qualified Data.Vector.Unboxed as VU>>> toVector (makeArrayR S Par (Sz2 5 6) (\(i :. j) -> i + j)) :: VU.Vector Int[0,1,2,3,4,5,1,2,3,4,5,6,2,3,4,5,6,7,3,4,5,6,7,8,4,5,6,7,8,9]
O(1) - conversion from Mutable array to a corresponding vector. Will
return Nothing only if source array representation was not one of B, N,
P, S or U.