diff options
Diffstat (limited to 'testsuite/tests/dph/quickhull/Main.hs')
-rw-r--r-- | testsuite/tests/dph/quickhull/Main.hs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/testsuite/tests/dph/quickhull/Main.hs b/testsuite/tests/dph/quickhull/Main.hs new file mode 100644 index 0000000000..ec59390850 --- /dev/null +++ b/testsuite/tests/dph/quickhull/Main.hs @@ -0,0 +1,43 @@ + +import qualified Types as QH +import QuickHullVect (quickhull) + +import qualified Data.Array.Parallel.Unlifted as U +import qualified Data.Array.Parallel.Prelude as P + +import qualified Data.Array.Parallel.PArray as P +import Data.Array.Parallel.PArray (PArray) + +import System.Environment +import Data.List + +import SVG +import TestData + + +----- +runQuickhull :: PArray QH.Point -> [(Double, Double)] +runQuickhull pts + = let result = quickhull pts + resxs = P.toUArrPA (QH.xsOf result) + resys = P.toUArrPA (QH.ysOf result) + in resxs U.!: 0 `seq` (zip (U.toList resxs) (U.toList resys)) + + +-- Main Program --------------------------------------------------------------- +main + = do args <- getArgs + let n = case args of + [s] -> read s + _ -> 1000 + + paInput <- toPArrayPoints + $ genPointsCombo n + + let psHull = runQuickhull paInput + psInput = P.toList paInput + + putStr + $ makeSVG + (roundPoints psInput) + (roundPoints psHull) |