Evaluate polynomial interpolation at the given time point. Args: coefficients: list of Tensor coefficients as created by `interp_fit`. t0: scalar float64 Tensor giving the start of the interval. t1: scalar float64 Tensor giving the end of the interval. t: scalar float64 Tensor giv
(coefficients, t0, t1, t)
| 182 | |
| 183 | |
| 184 | def _interp_evaluate(coefficients, t0, t1, t): |
| 185 | """Evaluate polynomial interpolation at the given time point. |
| 186 | |
| 187 | Args: |
| 188 | coefficients: list of Tensor coefficients as created by `interp_fit`. |
| 189 | t0: scalar float64 Tensor giving the start of the interval. |
| 190 | t1: scalar float64 Tensor giving the end of the interval. |
| 191 | t: scalar float64 Tensor giving the desired interpolation point. |
| 192 | |
| 193 | Returns: |
| 194 | Polynomial interpolation of the coefficients at time `t`. |
| 195 | """ |
| 196 | with ops.name_scope('interp_evaluate'): |
| 197 | t0 = ops.convert_to_tensor(t0) |
| 198 | t1 = ops.convert_to_tensor(t1) |
| 199 | t = ops.convert_to_tensor(t) |
| 200 | |
| 201 | dtype = coefficients[0].dtype |
| 202 | |
| 203 | assert_op = control_flow_ops.Assert( |
| 204 | (t0 <= t) & (t <= t1), |
| 205 | ['invalid interpolation, fails `t0 <= t <= t1`:', t0, t, t1]) |
| 206 | with ops.control_dependencies([assert_op]): |
| 207 | x = math_ops.cast((t - t0) / (t1 - t0), dtype) |
| 208 | |
| 209 | xs = [constant_op.constant(1, dtype), x] |
| 210 | for _ in range(2, len(coefficients)): |
| 211 | xs.append(xs[-1] * x) |
| 212 | |
| 213 | return _dot_product(coefficients, reversed(xs)) |
| 214 | |
| 215 | |
| 216 | def _optimal_step_size(last_step, |
no test coverage detected