diff options
Diffstat (limited to 'testsuite/tests/dph/smvm/SMVMVect.hs')
-rw-r--r-- | testsuite/tests/dph/smvm/SMVMVect.hs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/testsuite/tests/dph/smvm/SMVMVect.hs b/testsuite/tests/dph/smvm/SMVMVect.hs new file mode 100644 index 0000000000..93f3775741 --- /dev/null +++ b/testsuite/tests/dph/smvm/SMVMVect.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE ParallelArrays #-} +{-# OPTIONS -fvectorise #-} +module SMVMVect (smvm) where + +import Data.Array.Parallel +import Data.Array.Parallel.Prelude.Double as D +import Data.Array.Parallel.Prelude.Int as I + +import qualified Prelude as P + +smvm :: PArray (PArray (Int, Double)) -> PArray Double -> PArray Double +{-# NOINLINE smvm #-} +smvm m v = toPArrayP (smvm' (fromNestedPArrayP m) (fromPArrayP v)) + +smvm' :: [:[: (Int, Double) :]:] -> [:Double:] -> [:Double:] +smvm' m v = [: D.sumP [: x D.* (v !: i) | (i,x) <- row :] | row <- m :] + |