% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gen-namespace-docs.R,
%   R/gen-namespace-examples.R, R/gen-namespace.R
\name{torch_diag}
\alias{torch_diag}
\title{Diag}
\usage{
torch_diag(self, diagonal = 0L)
}
\arguments{
\item{self}{(Tensor) the input tensor.}

\item{diagonal}{(int, optional) the diagonal to consider}
}
\description{
Diag
}
\section{diag(input, diagonal=0, out=NULL) -> Tensor }{

\itemize{
\item If \code{input} is a vector (1-D tensor), then returns a 2-D square tensor
with the elements of \code{input} as the diagonal.
\item If \code{input} is a matrix (2-D tensor), then returns a 1-D tensor with
the diagonal elements of \code{input}.
}

The argument \code{diagonal} controls which diagonal to consider:
\itemize{
\item If \code{diagonal} = 0, it is the main diagonal.
\item If \code{diagonal} > 0, it is above the main diagonal.
\item If \code{diagonal} < 0, it is below the main diagonal.
}
}

