tcrossprod.HDF5Matrix: Transposed cross product of HDF5Matrix objects

View source: R/S3_algebra.R

tcrossprodR Documentation

Transposed cross product of HDF5Matrix objects

Description

S3 generic for tcrossprod(). Dispatches to tcrossprod.HDF5Matrix for HDF5Matrix objects, and to base::tcrossprod() for all others.

Usage

tcrossprod(x, y = NULL, ...)

## S3 method for class 'HDF5Matrix'
tcrossprod(x, y = NULL, outgroup = NULL, outdataset = NULL, ...)

Arguments

x

An HDF5Matrix object.

y

An HDF5Matrix object, or NULL (default) to compute x %*% t(x).

...

Ignored.

outgroup

Character or NULL. HDF5 group where the result is stored. Default "OUTPUT".

outdataset

Character or NULL. Dataset name for the result. Default "tCrossProd_x" (single matrix) or "tCrossProd_x_x_y" (two matrices).

Details

Computes x \times t(y) (or x \times t(x) when y = NULL). Uses the dedicated BigDataStatMeth block-wise transposed cross-product algorithm, which is more efficient than explicitly computing x %*% t(y).

Performance settings:

This method uses global options set via hdf5matrix_options.

Symmetric optimization:

When y = NULL or y refers to the same dataset as x, the symmetric optimisation is applied automatically, providing significant speedup.

Value

Result of the cross product.

A new HDF5Matrix pointing to the result dataset.

See Also

hdf5matrix_options for global performance settings

Examples


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 <- tcrossprod(X)
dim(C1)

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

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

hdf5_close_all()
unlink(fn)



BigDataStatMeth documentation built on May 15, 2026, 1:07 a.m.