crossprod: Matrix Crossproduct

crossprodR Documentation

Matrix Crossproduct

Description

Matrix Crossproduct

Usage

## S4 method for signature 'AbstractLazyArray,AbstractLazyArray'
crossprod(x, y = NULL, weights = NULL, ...)

## S4 method for signature 'AbstractLazyArray,'NULL''
crossprod(x, y = NULL, weights = NULL, ...)

## S4 method for signature 'AbstractLazyArray,missing'
crossprod(x, y = NULL, weights = NULL, ...)

## S4 method for signature 'AbstractLazyArray,matrix'
crossprod(x, y = NULL, weights = NULL, ...)

Arguments

x

a LazyArray or an R matrix

y

NULL or matrix

weights

numeric vector used as weight

...

passed to further methods

Value

Matrix of cross product if data is small, or LazyMatrix if matrix is too large

Examples


x <- matrix(1:100, 50)
crossprod(x)

lazy_x <- as.lazymatrix(x)
crossprod(lazy_x)[]

weights <- (1:50)/50

t(x) %*% diag(weights) %*% x
crossprod(lazy_x, weights = weights)

## Not run: 

# large data set ~ 1.6GB
x <- as.lazymatrix(matrix(rnorm(2e8), ncol = 2))

crossprod(x)

## End(Not run)



dipterix/lazyarray documentation built on June 30, 2023, 6:30 a.m.