torchcurves.functional.legendre_curves#
- torchcurves.functional.legendre_curves(x, coefficients, checkpoint_segments=None)#
Evaluate curves parametrized by Legendre polynomials.
- Parameters:
coefficients (
Tensor) – A tensor of size \((N, C, D)\) of curve coefficients, of a set of \(C\) polynomial curves in \(\mathbb{R}^D\) of degree \(N-1\), represented in the Legendre basis.x (
Tensor) – Batch of size \((B, C)\), wherex[:, j]is the batch of inputs for the j-th curve in the batch.checkpoint_segments (
Optional[int]) – Optional number of segments for gradient checkpointing. Larger values save memory but increase compute. Only used when gradients are enabled.
- Return type:
Tensor- Returns:
Evaluated points on the curves, shape \((B, C, D)\).
Note
Uses the Clenshaw recursive algorithm, and thus requires \(O(N)\) time. Implementation is vectorized along the \(B\) and \(D\) dimensions, but the algorithm requires a loop over the polynomial degree.