Last active
January 22, 2024 20:58
-
-
Save tomsmeding/fff9b01cf04ed59bf353220b235f52b8 to your computer and use it in GitHub Desktop.
Manually simulate prop_partition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Fill in the a, b, ps values from the quickhull-test failure message for the | |
-- 'partition' test below. Then start `cabal repl` and copy-paste this whole | |
-- thing in there. The output of the last command is what your 'partition' does | |
-- on this input. | |
import Data.Array.Accelerate.Interpreter | |
-- paste the printed values of a, b and ps here | |
a = (-454, -137) | |
b = (-286, -641) | |
ps = [(-398, -69), (-376, -135)] | |
let leftOf ((x1, y1), (x2, y2)) (x, y) = let nx = y1 - y2 ; ny = x2 - x1 in nx * x + ny * y P.> nx * x1 + ny * y1 | |
let p1 = P.min a b | |
let p2 = P.max a b | |
let us = Data.List.nub $ Data.List.sort $ P.filter (leftOf (p1,p2)) ps | |
let vs = Data.List.nub $ Data.List.sort $ P.filter (leftOf (p2,p1)) ps | |
let nus = P.length us | |
let nvs = P.length vs | |
let n = nus + nvs + 3 | |
let flags = True : P.replicate nus False P.++ [True] P.++ P.replicate nvs False P.++ [True] | |
let points = p1 : us P.++ [p2] P.++ vs P.++ [p1] | |
runN partition (fromList (Z :. n) flags, fromList (Z :. n) points) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment