% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/S3_algebra.R
\name{crossprod}
\alias{crossprod}
\alias{crossprod.HDF5Matrix}
\title{Cross product of HDF5Matrix objects}
\usage{
crossprod(x, y = NULL, ...)

\method{crossprod}{HDF5Matrix}(x, y = NULL, outgroup = NULL, outdataset = NULL, ...)
}
\arguments{
\item{x}{An \code{HDF5Matrix} object.}

\item{y}{An \code{HDF5Matrix} object, or \code{NULL} (default) to
compute \code{t(x) \%*\% x}.}

\item{...}{Ignored.}

\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.
Default \code{"CrossProd_x"} (single matrix) or
\code{"CrossProd_x_x_y"} (two matrices).}
}
\value{
Result of the cross product.

A new \code{HDF5Matrix} pointing to the result dataset.
}
\description{
S3 generic for \code{crossprod()}. Dispatches to
\code{\link{crossprod.HDF5Matrix}} for \code{HDF5Matrix} objects,
and to \code{base::crossprod()} for all others.
}
\details{
Computes \eqn{t(x) \times y} (or \eqn{t(x) \times x} when \code{y = NULL}).
Uses the dedicated BigDataStatMeth block-wise cross-product algorithm, which
is more efficient than explicitly computing \code{t(x) \%*\% y}.

\strong{Performance settings:}

This method uses global options set via \code{\link{hdf5matrix_options}}.

\strong{Symmetric optimization:}

When \code{y = NULL} or \code{y} refers to the same dataset as \code{x},
the symmetric optimisation (\code{bisSymetric = TRUE}) is applied automatically,
providing significant speedup.
}
\examples{
\donttest{
fn <- tempfile(fileext = ".h5")
X <- hdf5_create_matrix(fn, "INPUT/X", data = matrix(rnorm(60), 6, 10))
Y <- hdf5_create_matrix(fn, "INPUT/Y", data = matrix(rnorm(60), 6, 10))

# t(X) \%*\% X  → stored in OUTPUT/CrossProd_X
C1 <- crossprod(X)
dim(C1)

# t(X) \%*\% Y  → stored in OUTPUT/CrossProd_X_x_Y
C2 <- crossprod(X, Y)

# Custom output location
C3 <- crossprod(X, outgroup = "RESULTS", outdataset = "my_crossprod")

hdf5_close_all()
unlink(fn)
}

}
\seealso{
\code{\link{hdf5matrix_options}} for global performance settings
}
