mr2.utils.filters.dct_matrix

mr2.utils.filters.dct_matrix(n: int, dtype: dtype = torch.float32) → Tensor[source]

Create the orthonormal discrete cosine transform of type II.

The rows are cosine basis vectors, indexed by increasing frequency. For \(k,m=0,\ldots,n-1\),

\[C_{k,m} = \alpha_k\cos\!\left(\frac{\pi k(m+1/2)}{n}\right), \qquad \alpha_0 = n^{-1/2},\quad \alpha_{k>0} = (2/n)^{1/2}.\]

C @ x computes the DCT-II of a length-n vector, and C.T applies its inverse. The first row is the constant (DC) basis vector.

Parameters:
  • n (int) – Number of samples and basis vectors.

  • dtype (dtype, default: torch.float32) – Floating dtype of the matrix.

Returns:

Orthonormal DCT-II matrix of shape (n, n).