aesara.tensor.diag

Contents

aesara.tensor.diag#

aesara.tensor.diag(v, k=0)[source]#

A helper function for two ops: ExtractDiag and AllocDiag. The name diag is meant to keep it consistent with numpy. It both accepts tensor vector and tensor matrix. While the passed tensor variable v has v.ndim>=2, it builds a ExtractDiag instance, and returns a vector with its entries equal to v’s main diagonal; otherwise if v.ndim is 1, it builds an AllocDiag instance, and returns a matrix with v at its k-th diaogonal.

Parameters:
  • v (symbolic tensor) –

  • k (int) – offset

Returns:

tensor

Return type:

symbolic tensor