Commit 2547ef83 authored by rl@cse.unsw.edu.au's avatar rl@cse.unsw.edu.au
Browse files

Add singletonSU

parent 087277b8
......@@ -93,7 +93,7 @@ module Data.Array.Parallel.Unlifted (
concatSU, flattenSU, (>:), segmentU, segmentArrU,
-- * Basic operations (segmented)
lengthSU, replicateSU, (+:+^),
lengthSU, singletonSU, replicateSU, (+:+^),
-- * Basic operations lifted
lengthsSU,
......
......@@ -28,7 +28,7 @@ module Data.Array.Parallel.Unlifted.Segmented (
concatSU, flattenSU, (>:), segmentU, segmentArrU, segdSU,
-- * Basic operations
lengthSU, replicateSU, sliceIndexSU, extractIndexSU, (+:+^),
lengthSU, singletonSU, replicateSU, sliceIndexSU, extractIndexSU, (+:+^),
-- * Basic operations lifted
lengthsSU,
......
......@@ -17,7 +17,7 @@
--
module Data.Array.Parallel.Unlifted.Segmented.Basics (
lengthSU, replicateSU,
lengthSU, singletonSU, replicateSU,
flattenSU, (>:), segmentU, segmentArrU, concatSU,
sliceIndexSU, extractIndexSU,
fstSU, sndSU, zipSU,
......@@ -32,16 +32,15 @@ import Data.Array.Parallel.Stream (
replicateEachS, zipS)
import Data.Array.Parallel.Unlifted.Flat (
UA, UArr,
(!:), sliceU, extractU,
lengthU, (!:), sliceU, extractU,
mapU, fstU, sndU, zipU, zipWith3U, sumU,
toU, fromU,
streamU, unstreamU)
import Data.Array.Parallel.Unlifted.Segmented.Stream (streamSU,unstreamSU)
import Data.Array.Parallel.Unlifted.Segmented.SUArr (
SUArr, lengthSU, (>:), flattenSU, segdSU, lengthsSU, indicesSU,
lengthsToUSegd)
lengthsToUSegd, singletonUSegd)
-- lengthSU reexported from SUArr
......@@ -50,6 +49,10 @@ import Data.Array.Parallel.Unlifted.Segmented.SUArr (
-- flattenSU and (>:) reexported from SUArr
singletonSU :: UA e => UArr e -> SUArr e
{-# INLINE singletonSU #-}
singletonSU es = singletonUSegd (lengthU es) >: es
replicateSU :: UA e => UArr Int -> UArr e -> SUArr e
{-# INLINE replicateSU #-}
replicateSU ns es =
......
......@@ -23,7 +23,7 @@ module Data.Array.Parallel.Unlifted.Segmented.USegd (
-- * Operations on segment descriptors
lengthUSegd, lengthsUSegd, indicesUSegd, fromUSegd,
lengthsToUSegd, toUSegd,
singletonUSegd, lengthsToUSegd, toUSegd,
sliceUSegd, extractUSegd,
newMUSegd, unsafeFreezeMUSegd,
) where
......@@ -32,7 +32,8 @@ import Data.Array.Parallel.Base (
(:*:)(..), ST)
import Data.Array.Parallel.Unlifted.Flat (
UArr, MUArr,
lengthU, (!:), sliceU, extractU, mapU, scanlU, mapAccumLU,
lengthU, singletonU, (!:), sliceU, extractU, mapU,
scanlU, mapAccumLU,
fstU, sndU, zipU,
streamU, unstreamU,
newMU, unsafeFreezeMU)
......@@ -93,6 +94,12 @@ toUSegd :: UArr (Int :*: Int) -> USegd
{-# INLINE toUSegd #-}
toUSegd = USegd
-- |Yield a singleton segment descriptor
--
singletonUSegd :: Int -> USegd
{-# INLINE singletonUSegd #-}
singletonUSegd n = toUSegd $ singletonU (n :*: 0)
-- |Convert a length array into a segment descriptor.
--
lengthsToUSegd :: UArr Int -> USegd
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment