def tree.same.as
import gralha-coverage@0.1.0.1/cover.bend as Coverimport Base
import gralha-text-scan@0.1.0.1/scan.bend as U
90# Coverage over the cell rectangle [x0, x1) by [y0, y1) of a node's square at
91# (nx, ny) of side size, when every cell in it holds the same value; -1 otherwise.
92# acc is 2 before any cell is seen, -1 once cells disagree, else the value so far.
93def tree.same.as(+v: F32, +u: F32) -> F32:
94 U.choose(F32, F32.is_gt(v, 1.5), u, U.choose(F32, F32.is_lt(v, 0.0) || F32.is_lt(u, 0.0) || Bool.not(F32.is_eq(v, u)), F32.neg(1.0), v))