The first-order linear recurrence looks inherently sequential, but each step is an affine map , and composing affine maps is associative. That is enough to compute all states in parallel passes. Implement the Hillis-Steele (doubling) inclusive scan.
parallel_linear_scan(a, b)
a and b are arrays of the same shape (L, ...); the recurrence runs along axis 0 and is elementwise over all trailing axes. and , so .(h, passes): h a float array of the same shape as b, and passes the number of passes performed (an int). Do not modify the inputs.a component in place first, the b update of the same pass reads the new values. Compute both from the old ones.