summaryrefslogtreecommitdiff
path: root/testsuite/tests/dph/quickhull/Main.hs
blob: ec593908503efa900defe16c43c31ad009c8c38f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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)