% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/S3_standalone.R
\name{hdf5_reduce}
\alias{hdf5_reduce}
\title{Reduce all datasets in an HDF5 group by a binary operation}
\usage{
hdf5_reduce(
  filename,
  group,
  func = "+",
  outgroup = NULL,
  outdataset = NULL,
  overwrite = FALSE,
  remove = FALSE
)
}
\arguments{
\item{filename}{Path to the HDF5 file.}

\item{group}{Group path containing the datasets to reduce.}

\item{func}{Character. Reduction operator: \code{"+"} (default)
or \code{"-"}.}

\item{outgroup}{Character or \code{NULL}. Output group
(default: same as \code{group}).}

\item{outdataset}{Character or \code{NULL}. Output dataset name
(default: same as \code{group}).}

\item{overwrite}{Logical. Overwrite existing output dataset.}

\item{remove}{Logical. Remove input datasets after reduction.}
}
\value{
An \code{HDF5Matrix} pointing to the result dataset.
}
\description{
Standalone function that applies a binary reduction (\code{"+"} or
\code{"-"}) across all datasets stored in a given HDF5 group and writes
the accumulated result as a new dataset. No open \code{HDF5Matrix} object
is required.
}
\details{
Use \code{hdf5_reduce()} when you only have the file path and group name.
If you already have an open \code{HDF5Matrix}, use
\code{\link{reduce}(x, ...)} instead — both produce the same result.

All datasets in \code{group} must have the same dimensions.
}
\examples{
\donttest{
fn <- tempfile(fileext = ".h5")
hdf5_create_matrix(fn, "blocks/A", data = matrix(1:6, 2, 3))
hdf5_create_matrix(fn, "blocks/B", data = matrix(1:6, 2, 3))
hdf5_create_matrix(fn, "blocks/C", data = matrix(1:6, 2, 3))
result <- hdf5_reduce(fn, group = "blocks", func = "+")
as.matrix(result)
hdf5_close_all()
unlink(fn)
}

}
\seealso{
\code{\link{hdf5_apply}}, \code{\link{cbind.HDF5Matrix}}
}
