% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/S3_operations.R
\name{split.HDF5Matrix}
\alias{split.HDF5Matrix}
\title{Split an HDF5Matrix into a list of blocks}
\usage{
\method{split}{HDF5Matrix}(
  x,
  f = NULL,
  drop = FALSE,
  n_blocks = -1L,
  block_size = -1L,
  bycols = FALSE,
  out_group = "SPLIT",
  out_dataset = NULL,
  overwrite = FALSE,
  ...
)
}
\arguments{
\item{x}{An \code{HDF5Matrix}.}

\item{f}{Ignored (kept for S3 signature compatibility).}

\item{drop}{Ignored (S3 compatibility).}

\item{n_blocks}{Integer. Number of (roughly equal) blocks; -1 = unused.}

\item{block_size}{Integer. Max rows (or cols) per block; -1 = unused.}

\item{bycols}{Logical. If \code{TRUE}, split by columns (default = by rows).}

\item{out_group}{Character. HDF5 group for output blocks (default \code{"SPLIT"}).}

\item{out_dataset}{Character or NULL. Base dataset name.}

\item{overwrite}{Logical. Overwrite existing blocks (default \code{FALSE}).}

\item{...}{Ignored.}
}
\value{
Named list of \code{HDF5Matrix} objects:
\code{block_0}, \code{block_1}, …
}
\description{
S3 method of \code{base::split()} for \code{HDF5Matrix} objects.
Divides the matrix into equal-sized blocks along rows (default) or columns,
storing each block as a separate dataset in the same HDF5 file.

Provide exactly ONE of \code{n_blocks} or \code{block_size}.
}
\details{
\strong{Calling convention:} use \code{split(x, n_blocks = 4)} after loading
the package. The form \code{BigDataStatMeth::split()} produces an error
because \code{split} is a \code{base} generic — this is normal R behaviour,
identical to \code{BigDataStatMeth::cor()} or \code{BigDataStatMeth::svd()}.
The S3 dispatch happens automatically when the package is loaded.

\code{split_dataset()} is an alternative with a cleaner signature that
omits the \code{f} and \code{drop} parameters inherited from
\code{base::split} (which have no meaning for HDF5Matrix objects).
Both functions produce identical results.
}
\examples{
\donttest{
fn     <- tempfile(fileext = ".h5")
X      <- hdf5_create_matrix(fn, "data/X", data = matrix(rnorm(2000), 20, 100))
blocks <- split(X, n_blocks = 4)   # 4 row-blocks of 5 rows each
length(blocks)                     # 4
lapply(blocks, close)

hdf5_close_all()
unlink(fn)
}

}
\seealso{
\code{\link{split_dataset}} for the equivalent with a cleaner
signature; \code{\link{hdf5_reduce}} to recombine blocks after processing.
}
