def Vec4.max_upto
import bend-tensors@0.0.0.2/bend_tensors.bend as BendTensorsimport Base
337# the largest of the first k elements
338def Vec4.max_upto(k: Nat, v: Vec4) -> F32:
339 match k v:
340 case 1n Vec4{x0, x1, x2, x3}:
341 x0
342 case 2n Vec4{x0, x1, x2, x3}:
343 F32.max(x0, x1)
344 case 3n Vec4{x0, x1, x2, x3}:
345 F32.max(F32.max(x0, x1), x2)
346 case _ v2:
347 Vec4.max(v2)