summaryrefslogtreecommitdiff
path: root/testsuite/tests/dph/primespj/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/dph/primespj/Main.hs')
-rw-r--r--testsuite/tests/dph/primespj/Main.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/testsuite/tests/dph/primespj/Main.hs b/testsuite/tests/dph/primespj/Main.hs
new file mode 100644
index 0000000000..049e6a3e04
--- /dev/null
+++ b/testsuite/tests/dph/primespj/Main.hs
@@ -0,0 +1,30 @@
+import Control.Exception (evaluate)
+import System.Console.GetOpt
+
+import Data.Array.Parallel.PArray (PArray)
+import qualified Data.Array.Parallel.PArray as P
+
+import PrimesVect (primesVect)
+import Debug.Trace
+
+
+primesList :: Int -> [Int]
+primesList 1 = []
+primesList n = sps ++ [ i | i <- [sq+1..n], multiple sps i ]
+ where
+ sps = primesList sq
+ sq = floor $ sqrt $ fromIntegral n
+
+ multiple :: [Int] -> Int -> Bool
+ multiple ps i = and [i `mod` p /= 0 | p <- ps]
+
+
+main
+ = do let n = 1000
+ let resultViaNDP = P.toList $ primesVect n
+ let resultViaLists = primesList n
+
+ print resultViaNDP
+ print resultViaLists
+ print $ resultViaNDP == resultViaLists
+