我有两个 Repa 数组a1
,a2
并且我想消除a2
其中相应索引a1
高于某个阈值的所有元素。例如:
import qualified Data.Array.Repa as R -- for Repa
import Data.Array.Repa (Z (..), (:.)(..))
a1 = R.fromFunction (Z :. 4) $ \(Z :. x) -> [8, 15, 9, 14] ! x
a2 = R.fromFunction (Z :. 4) $ \(Z :. x) -> [0, 1, 2, 3] ! x
threshold = 10
desired = R.fromFunction (Z :. 2) $ \(Z :. x) -> [0, 2] ! x
-- 15 and 14 are above the threshold, 10
一种方法是使用,selectP
但我想避免使用它,因为它计算数组,如果可能的话,我希望我的数组保持延迟形式。
另一种方法是使用repa-array
,但stack solver
似乎不知道如何使用解析器导入此库nightly-2017-04-10
。