blob: 162458f424bea75fa00cdee86efbb17b9438fdb9 (
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
|
{-# LANGUAGE ParallelArrays #-}
{-# OPTIONS -fvectorise #-}
module Types ( Point, Line, points, xsOf, ysOf) where
import Data.Array.Parallel
type Point = (Double, Double)
type Line = (Point, Point)
points' :: [:Double:] -> [:Double:] -> [:Point:]
points' = zipP
points :: PArray Double -> PArray Double -> PArray Point
{-# NOINLINE points #-}
points xs ys = toPArrayP (points' (fromPArrayP xs) (fromPArrayP ys))
xsOf' :: [:Point:] -> [:Double:]
xsOf' ps = [: x | (x, _) <- ps :]
xsOf :: PArray Point -> PArray Double
{-# NOINLINE xsOf #-}
xsOf ps = toPArrayP (xsOf' (fromPArrayP ps))
ysOf' :: [:Point:] -> [:Double:]
ysOf' ps = [: y | (_, y) <- ps :]
ysOf :: PArray Point -> PArray Double
{-# NOINLINE ysOf #-}
ysOf ps = toPArrayP (ysOf' (fromPArrayP ps))
|