MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _interp_evaluate

Function _interp_evaluate

tensorflow/contrib/integrate/python/ops/odes.py:184–213  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

182
183
184def _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
216def _optimal_step_size(last_step,

Callers 1

interpolateFunction · 0.85

Calls 7

_dot_productFunction · 0.85
rangeFunction · 0.50
name_scopeMethod · 0.45
control_dependenciesMethod · 0.45
castMethod · 0.45
constantMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected