{-# LANGUAGE BangPatterns #-}moduleData.Array.Repa.Operators.Selection(select)whereimportData.Array.Repa.IndeximportData.Array.Repa.BaseimportData.Array.Repa.Eval.SelectionimportData.Array.Repa.Repr.UnboxedasUimportqualifiedData.Vector.UnboxedasVimportSystem.IO.Unsafe-- | Produce an array by applying a predicate to a range of integers.-- If the predicate matches, then use the second function to generate-- the element.---- * This is a low-level function helpful for writing filtering-- operations on arrays.---- * Use the integer as the index into the array you're filtering.--select::Unboxa=>(Int->Bool)-- ^ If the Int matches this predicate,->(Int->a)-- ^ ... then pass it to this fn to produce a value->Int-- ^ Range between 0 and this maximum.->ArrayUDIM1a-- ^ Array containing produced values.{-# INLINE [2] select #-}selectmatchproducelen=unsafePerformIO$do(sh,vec)<-selectIOreturn$sh`seq`vec`seq`fromUnboxedshvecwhere{-# INLINE selectIO #-}selectIO=dovecs<-selectChunkedPmatchproducelenvecs'<-mapMV.unsafeFreezevecs-- TODO: avoid copy somehow.letresult=V.concatvecs'return(Z:.V.lengthresult,result)