% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/S3_matvec.R
\name{diag}
\alias{diag}
\alias{diag.default}
\alias{diag.HDF5Matrix}
\title{Extract or construct a diagonal for HDF5Matrix}
\usage{
diag(x, ...)

\method{diag}{default}(x, nrow, ncol, names = TRUE, ...)

\method{diag}{HDF5Matrix}(x, ...)
}
\arguments{
\item{x}{An \code{HDF5Matrix} or any object accepted by \code{base::diag()}.}

\item{...}{Ignored.}

\item{nrow}{Passed to \code{base::diag()} for non-HDF5Matrix objects.}

\item{ncol}{Passed to \code{base::diag()} for non-HDF5Matrix objects.}

\item{names}{Passed to \code{base::diag()} for non-HDF5Matrix objects.}
}
\value{
For \code{HDF5Matrix}: numeric vector of diagonal elements.
For plain R objects: result of \code{base::diag()}.
}
\description{
Overrides \code{base::diag()} to dispatch on \code{HDF5Matrix} objects.
For plain R matrices/vectors the call is forwarded to \code{base::diag()}.

When \code{x} is an \code{HDF5Matrix}, extracts the diagonal as an
in-memory numeric vector (length = min(nrow, ncol)).
}
\seealso{
\code{\link[base]{diag}}
}
