summaryrefslogtreecommitdiff
path: root/testsuite/tests/dph/smvm/SMVMVect.hs
blob: 93f37757418b7e5f28030ae85b6cf13814cf5240 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 :]