MCPcopy Create free account
hub / github.com/HazyResearch/spacetime / construct_toeplitz

Function construct_toeplitz

model/functional/toeplitz.py:17–33  ·  view source on GitHub ↗

Explicit construction of Krylov matrix [v A @ v A^2 @ v ... A^{n-1} @ v] where A = Z_f. This uses vectorized indexing and cumprod so it's much faster than using the Krylov function. Parameters: v: the starting vector of size n or (rank, n). f: real number Returns:

(v, f=0.0)

Source from the content-addressed store, hash-verified

15
16
17def construct_toeplitz(v, f=0.0):
18 """Explicit construction of Krylov matrix [v A @ v A^2 @ v ... A^{n-1} @ v]
19 where A = Z_f. This uses vectorized indexing and cumprod so it's much
20 faster than using the Krylov function.
21 Parameters:
22 v: the starting vector of size n or (rank, n).
23 f: real number
24 Returns:
25 K: Krylov matrix of size (n, n) or (rank, n, n).
26 """
27 n = v.shape[-1]
28 a = torch.arange(n, device=v.device)
29 b = -a
30 indices = a[:, None] + b[None]
31 K = v[..., indices]
32 K[..., indices < 0] *= f
33 return K
34
35def triangular_toeplitz_multiply_(u, v, sum=None):
36 n = u.shape[-1]

Callers 1

toeplitz.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected