aesara.tensor.diag#
- aesara.tensor.diag(v, k=0)[source]#
A helper function for two ops:
ExtractDiag
andAllocDiag
. The namediag
is meant to keep it consistent with numpy. It both accepts tensor vector and tensor matrix. While the passed tensor variablev
hasv.ndim>=2
, it builds aExtractDiag
instance, and returns a vector with its entries equal tov
’s main diagonal; otherwise ifv.ndim
is1
, it builds anAllocDiag
instance, and returns a matrix withv
at its k-th diaogonal.- Parameters:
v (symbolic tensor) –
k (int) – offset
- Returns:
tensor
- Return type:
symbolic tensor