% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/S3_standalone.R
\name{hdf5_apply}
\alias{hdf5_apply}
\title{Apply a mathematical operation to multiple HDF5 datasets}
\usage{
hdf5_apply(
  filename,
  group,
  datasets,
  func,
  outgroup,
  b_group = NULL,
  b_datasets = NULL,
  overwrite = FALSE,
  transp_dataset = FALSE,
  transp_bdataset = FALSE,
  fullMatrix = FALSE,
  byrows = FALSE,
  threads = NULL
)
}
\arguments{
\item{filename}{Path to the HDF5 file.}

\item{group}{Group path containing \code{datasets}.}

\item{datasets}{Character vector of dataset names to process.}

\item{func}{Character. Operation to apply (see Details).}

\item{outgroup}{Character. Output group path for results.}

\item{b_group}{Character or \code{NULL}. Group of B datasets.}

\item{b_datasets}{Character vector or \code{NULL}. Names of B datasets.}

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

\item{transp_dataset}{Logical. Transpose A datasets before operation.}

\item{transp_bdataset}{Logical. Transpose B datasets before operation.}

\item{fullMatrix}{Logical. Return full matrix (not triangular).}

\item{byrows}{Logical. Apply by rows (for normalize/sdmean).}

\item{threads}{Integer or \code{NULL}. OpenMP threads.}
}
\value{
Invisibly \code{NULL}. Results written to \code{outgroup}.
Open them with \code{\link{hdf5_matrix}()}.
}
\description{
Standalone function that applies a predefined algebraic or statistical
operation to a list of datasets stored in an HDF5 group, writing results
to \code{outgroup}. No open \code{HDF5Matrix} object is required.

\strong{This is not equivalent to \code{base::apply()}.} It dispatches
built-in C++ operations (QR, cross-product, Cholesky, etc.) to a batch of
named datasets in the file.
}
\details{
Use \code{hdf5_apply()} when you only have the file path and group name.
If you already have an open \code{HDF5Matrix}, use
\code{\link{apply_function}(x, ...)} instead — both produce the same result.

\describe{
\item{\code{"CrossProd"}}{Compute \eqn{A^T A} for each dataset.}
\item{\code{"tCrossProd"}}{Compute \eqn{A A^T} for each dataset.}
\item{\code{"CrossProd_double"}}{Double-precision cross-product.}
\item{\code{"tCrossProd_double"}}{Double-precision transposed cross-product.}
\item{\code{"blockmult"}}{Block-wise \eqn{A \times B}
(requires \code{b_datasets}).}
\item{\code{"QR"}}{QR decomposition for each dataset.}
\item{\code{"invChol"}}{Inverse via Cholesky for each dataset.}
\item{\code{"solve"}}{Solve \eqn{AX = B}
(requires \code{b_datasets}).}
\item{\code{"normalize"}}{Column-wise normalization.}
\item{\code{"sdmean"}}{Compute SD and mean.}
\item{\code{"descChol"}}{Cholesky decomposition.}
}
}
\examples{
\donttest{
tmp <- tempfile(fileext = ".h5")
A <- hdf5_create_matrix(tmp, "inp/A", data = matrix(rnorm(25), 5, 5))
B <- hdf5_create_matrix(tmp, "inp/B", data = matrix(rnorm(25), 5, 5))
hdf5_apply(tmp, group = "inp", datasets = c("A", "B"), 
func = "CrossProd", outgroup = "out")
res <- list_datasets(tmp)
res
res_A <- hdf5_matrix(tmp, res[3])
dim(res_A)   # 5 x 5
close(res_A)
hdf5_close_all()
unlink(tmp)
}

}
\seealso{
\code{\link{apply_function}} for the S3 method on an open
\code{HDF5Matrix}; \code{\link{hdf5_reduce}} for group-level reduction.
}
