MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / evaluate

Method evaluate

utils/strand_util.py:271–284  ·  view source on GitHub ↗
(self, t)

Source from the content-addressed store, hash-verified

269 self._d = d
270
271 def evaluate(self, t):
272 maxlen = self._b.size(-2) - 1
273 inners = torch.zeros((t.shape[0], t.shape[1], 3)).to(t.device)
274 for i_b in range(self._t.shape[0]):
275 index = torch.bucketize(t.detach()[i_b], self._t[i_b]) - 1
276 index = index.clamp(0, maxlen) # clamp because t may go outside of [t[0], t[-1]]; this is fine
277 # will never access the last element of self._t; this is correct behaviour
278 fractional_part = t[i_b] - self._t[i_b][index]
279 fractional_part = fractional_part.unsqueeze(-1)
280 inner = self._c[i_b, index, :] + self._d[i_b, index, :] * fractional_part
281 inner = self._b[i_b, index, :] + inner * fractional_part
282 inner = self._a[i_b, index, :] + inner * fractional_part
283 inners[i_b] = inner
284 return inners
285
286 def derivative(self, t, order=1):
287 fractional_part, index = self._interpret_t(t)

Callers 2

diff_splineFunction · 0.95
spline_strandFunction · 0.80

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected