Compute the linear interpolation weighted by gamma on each point of two same shape array. a : array_like Left bound. b : array_like Right bound. t : array_like The interpolation weight. out : array_like Output array.
(a, b, t, out=None)
| 4592 | |
| 4593 | |
| 4594 | def _lerp(a, b, t, out=None): |
| 4595 | """ |
| 4596 | Compute the linear interpolation weighted by gamma on each point of |
| 4597 | two same shape array. |
| 4598 | |
| 4599 | a : array_like |
| 4600 | Left bound. |
| 4601 | b : array_like |
| 4602 | Right bound. |
| 4603 | t : array_like |
| 4604 | The interpolation weight. |
| 4605 | out : array_like |
| 4606 | Output array. |
| 4607 | """ |
| 4608 | diff_b_a = b - a |
| 4609 | lerp_interpolation = add(a, diff_b_a * t, out=... if out is None else out) |
| 4610 | subtract(b, diff_b_a * (1 - t), out=lerp_interpolation, where=t >= 0.5, |
| 4611 | casting='unsafe', dtype=type(lerp_interpolation.dtype)) |
| 4612 | if lerp_interpolation.ndim == 0 and out is None: |
| 4613 | lerp_interpolation = lerp_interpolation[()] # unpack 0d arrays |
| 4614 | return lerp_interpolation |
| 4615 | |
| 4616 | |
| 4617 | def _get_gamma_mask(shape, default_value, conditioned_value, where): |