Skip to content

Instantly share code, notes, and snippets.

@tmcdonell
Created October 18, 2018 13:51
Show Gist options
  • Save tmcdonell/10d3f5843a24e76916c6ed177aaae218 to your computer and use it in GitHub Desktop.
Save tmcdonell/10d3f5843a24e76916c6ed177aaae218 to your computer and use it in GitHub Desktop.
\a0 -> let a1 =
fold
(\x0 x1 -> x0 + x1)
0
(delayed
((intersect
(intersect
(intersect
(indexSlice Z :. 0 :. 0 :. All (shape a0))
(indexSlice Z :. 1 :. 0 :. All (shape a0)))
(indexSlice Z :. 0 :. 1 :. All (shape a0)))
(indexSlice Z :. 1 :. 1 :. All (shape a0))))
(\x0 -> boolToInt
(not
((((a0!(indexFull Z :. 0 :. 0 :. All x0))
||
(a0!(indexFull Z :. 1 :. 0 :. All x0)))
||
(a0!(indexFull Z :. 0 :. 1 :. All x0)))
||
(a0!(indexFull Z :. 1 :. 1 :. All x0)))))) in
let a2 = unit (a1!Z) in
let a3 = reshape Z :. 1 a2 in
let a4 =
permute
(\x0 x1 -> x0)
(generate Z :. 2 :. 2 :. 71 (\x0 -> 0))
(\x0 -> Z :. 0 :. 0 :. indexHead x0)
(delayed
((let x0 =
intersect
(intersect
(intersect Z :. 71 (indexSlice Z :. 1 :. 0 :. All (shape a0)))
(indexSlice Z :. 0 :. 1 :. All (shape a0)))
(indexSlice Z :. 1 :. 1 :. All (shape a0)) in
let x1 = shape a3 in
let x2 = (indexHead x0) + (indexHead x1)
in intersect (indexTail x0 :. x2) (indexTail x1 :. x2)))
(\x0 -> let x1 = indexHead x0 in
let x2 =
indexHead
(intersect
(intersect
(intersect Z :. 71 (indexSlice Z :. 1 :. 0 :. All (shape a0)))
(indexSlice Z :. 0 :. 1 :. All (shape a0)))
(indexSlice Z :. 1 :. 1 :. All (shape a0)))
in if x1 < x2
then ((boolToInt (a0!(indexFull Z :. 1 :. 0 :. All x0)))
+
(boolToInt (a0!(indexFull Z :. 0 :. 1 :. All x0))))
+
(boolToInt (a0!(indexFull Z :. 1 :. 1 :. All x0)))
else a3!(indexTail x0 :. x1 - x2))) in
let a5 =
fold
(\x0 x1 -> x0 + x1)
0
(delayed
((intersect
(intersect
(intersect
(indexSlice Z :. 0 :. 1 :. All (shape a0))
(indexSlice Z :. 0 :. 0 :. All (shape a0)))
(indexSlice Z :. 1 :. 0 :. All (shape a0)))
(indexSlice Z :. 1 :. 1 :. All (shape a0))))
(\x0 -> boolToInt
(not
((((a0!(indexFull Z :. 0 :. 1 :. All x0))
||
(a0!(indexFull Z :. 0 :. 0 :. All x0)))
||
(a0!(indexFull Z :. 1 :. 0 :. All x0)))
||
(a0!(indexFull Z :. 1 :. 1 :. All x0)))))) in
let a6 = unit (a5!Z) in
let a7 = reshape Z :. 1 a6 in
let a8 =
permute
(\x0 x1 -> x0)
a4
(\x0 -> Z :. 0 :. 1 :. indexHead x0)
(delayed
((let x0 =
intersect
(intersect
(intersect Z :. 71 (indexSlice Z :. 0 :. 0 :. All (shape a0)))
(indexSlice Z :. 1 :. 0 :. All (shape a0)))
(indexSlice Z :. 1 :. 1 :. All (shape a0)) in
let x1 = shape a7 in
let x2 = (indexHead x0) + (indexHead x1)
in intersect (indexTail x0 :. x2) (indexTail x1 :. x2)))
(\x0 -> let x1 = indexHead x0 in
let x2 =
indexHead
(intersect
(intersect
(intersect Z :. 71 (indexSlice Z :. 0 :. 0 :. All (shape a0)))
(indexSlice Z :. 1 :. 0 :. All (shape a0)))
(indexSlice Z :. 1 :. 1 :. All (shape a0)))
in if x1 < x2
then ((boolToInt (a0!(indexFull Z :. 0 :. 0 :. All x0)))
+
(boolToInt (a0!(indexFull Z :. 1 :. 0 :. All x0))))
+
(boolToInt (a0!(indexFull Z :. 1 :. 1 :. All x0)))
else a7!(indexTail x0 :. x1 - x2))) in
let a9 =
fold
(\x0 x1 -> x0 + x1)
0
(delayed
((intersect
(intersect
(intersect
(indexSlice Z :. 1 :. 0 :. All (shape a0))
(indexSlice Z :. 1 :. 1 :. All (shape a0)))
(indexSlice Z :. 0 :. 1 :. All (shape a0)))
(indexSlice Z :. 0 :. 0 :. All (shape a0))))
(\x0 -> boolToInt
(not
((((a0!(indexFull Z :. 1 :. 0 :. All x0))
||
(a0!(indexFull Z :. 1 :. 1 :. All x0)))
||
(a0!(indexFull Z :. 0 :. 1 :. All x0)))
||
(a0!(indexFull Z :. 0 :. 0 :. All x0)))))) in
let a10 = unit (a9!Z) in
let a11 = reshape Z :. 1 a10 in
let a12 =
permute
(\x0 x1 -> x0)
a8
(\x0 -> Z :. 1 :. 0 :. indexHead x0)
(delayed
((let x0 =
intersect
(intersect
(intersect Z :. 71 (indexSlice Z :. 1 :. 1 :. All (shape a0)))
(indexSlice Z :. 0 :. 1 :. All (shape a0)))
(indexSlice Z :. 0 :. 0 :. All (shape a0)) in
let x1 = shape a11 in
let x2 = (indexHead x0) + (indexHead x1)
in intersect (indexTail x0 :. x2) (indexTail x1 :. x2)))
(\x0 -> let x1 = indexHead x0 in
let x2 =
indexHead
(intersect
(intersect
(intersect Z :. 71 (indexSlice Z :. 1 :. 1 :. All (shape a0)))
(indexSlice Z :. 0 :. 1 :. All (shape a0)))
(indexSlice Z :. 0 :. 0 :. All (shape a0)))
in if x1 < x2
then ((boolToInt (a0!(indexFull Z :. 1 :. 1 :. All x0)))
+
(boolToInt (a0!(indexFull Z :. 0 :. 1 :. All x0))))
+
(boolToInt (a0!(indexFull Z :. 0 :. 0 :. All x0)))
else a11!(indexTail x0 :. x1 - x2))) in
let a13 =
fold
(\x0 x1 -> x0 + x1)
0
(delayed
((intersect
(intersect
(intersect
(indexSlice Z :. 1 :. 1 :. All (shape a0))
(indexSlice Z :. 1 :. 0 :. All (shape a0)))
(indexSlice Z :. 0 :. 1 :. All (shape a0)))
(indexSlice Z :. 0 :. 0 :. All (shape a0))))
(\x0 -> boolToInt
(not
((((a0!(indexFull Z :. 1 :. 1 :. All x0))
||
(a0!(indexFull Z :. 1 :. 0 :. All x0)))
||
(a0!(indexFull Z :. 0 :. 1 :. All x0)))
||
(a0!(indexFull Z :. 0 :. 0 :. All x0)))))) in
let a14 = unit (a13!Z) in
let a15 = reshape Z :. 1 a14
in permute
(\x0 x1 -> x0)
a12
(\x0 -> Z :. 1 :. 1 :. indexHead x0)
(delayed
((let x0 =
intersect
(intersect
(intersect Z :. 71 (indexSlice Z :. 1 :. 0 :. All (shape a0)))
(indexSlice Z :. 0 :. 1 :. All (shape a0)))
(indexSlice Z :. 0 :. 0 :. All (shape a0)) in
let x1 = shape a15 in
let x2 = (indexHead x0) + (indexHead x1)
in intersect (indexTail x0 :. x2) (indexTail x1 :. x2)))
(\x0 -> let x1 = indexHead x0 in
let x2 =
indexHead
(intersect
(intersect
(intersect Z :. 71 (indexSlice Z :. 1 :. 0 :. All (shape a0)))
(indexSlice Z :. 0 :. 1 :. All (shape a0)))
(indexSlice Z :. 0 :. 0 :. All (shape a0)))
in if x1 < x2
then ((boolToInt (a0!(indexFull Z :. 1 :. 0 :. All x0)))
+
(boolToInt (a0!(indexFull Z :. 0 :. 1 :. All x0))))
+
(boolToInt (a0!(indexFull Z :. 0 :. 0 :. All x0)))
else a15!(indexTail x0 :. x1 - x2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment