tcrossprod_gpu

Tensor-aware tcrossprod

Description

Computes x %% t(y) (or x %% t(x) if y is NULL) using the accelerator if either argument is a torch tensor and an accelerator is active; falls back to tcrossprod otherwise. Exposed so downstream packages (e.g. spiDE) can build their own GPU-blocked linear algebra with the same dual (tensor-or-matrix) semantics SpaNorm’s own fitting uses.

Usage

tcrossprod_gpu(x, y = NULL)

Arguments

x a matrix or torch tensor.
y a matrix or torch tensor, or NULL (default).

Value

x %*% t(y), as a matrix or torch tensor matching the input.

Examples

library("SpaNorm")

m <- matrix(rnorm(12), nrow = 3)
tcrossprod_gpu(m)
           [,1]      [,2]       [,3]
[1,]  3.2682144 0.3088139 -0.6237958
[2,]  0.3088139 2.9729059  0.5906629
[3,] -0.6237958 0.5906629  1.8549455