% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/S3_diagonal.R
\name{diag_op}
\alias{diag_op}
\alias{diag_op.HDF5Matrix}
\title{Diagonal-vector operation on an HDF5Matrix}
\usage{
diag_op(x, diag, op = "+", ...)

\method{diag_op}{HDF5Matrix}(x, diag, op = "+", outgroup = NULL, outdataset = NULL, ...)
}
\arguments{
\item{x}{An \code{HDF5Matrix} (matrix, \eqn{m \times n}).}

\item{diag}{An \code{HDF5Matrix} with one row or one column.}

\item{op}{Character. One of \code{"+"}, \code{"-"}, \code{"*"},
\code{"/"}.}

\item{\dots}{Additional arguments passed to \code{x$diag_op()}:
\code{outgroup}, \code{outdataset}, \code{overwrite},
\code{threads}, \code{compression}.}

\item{outgroup}{Character or \code{NULL}. HDF5 group where the result is
stored. Default \code{"OUTPUT"}.}

\item{outdataset}{Character or \code{NULL}. Dataset name for the result.}
}
\value{
A new \code{HDF5Matrix}.
}
\description{
Applies an element-wise binary operation between an
\code{HDF5Matrix} and a diagonal vector (a 1-row or 1-column
\code{HDF5Matrix}). The vector is broadcast across each row of the
matrix.

The standard arithmetic operators (\code{+}, \code{-}, \code{*},
\code{/}) dispatch automatically to this function when one operand is
a 1-row or 1-column \code{HDF5Matrix}.
}
\examples{
\donttest{
tmp <- tempfile(fileext = ".h5")
M   <- hdf5_create_matrix(tmp, "data/M", data = matrix(rnorm(10000), 100, 100))
d   <- hdf5_create_matrix(tmp, "data/d", data = matrix(rnorm(10000), 100, 100))
R1  <- diag_op(M, d, "*")    # scale each column
R2  <- M * d                  # same via operator auto-dispatch
hdf5_close_all()
unlink(tmp)
}

}
\seealso{
\code{\link{diag_scale}}
}
