# big_cprodMat: Cross-product with a matrix In bigstatsr: Statistical Tools for Filebacked Big Matrices

## Description

Cross-product between a Filebacked Big Matrix and a matrix.

## Usage

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 big_cprodMat( X, A.row, ind.row = rows_along(X), ind.col = cols_along(X), ncores = 1, block.size = block_size(nrow(X), ncores), center = NULL, scale = NULL ) ## S4 method for signature 'FBM,matrix' crossprod(x, y) ## S4 method for signature 'FBM,matrix' tcrossprod(x, y) ## S4 method for signature 'matrix,FBM' crossprod(x, y) ## S4 method for signature 'matrix,FBM' tcrossprod(x, y) 

## Arguments

 X An object of class FBM. A.row A matrix with length(ind.row) rows. ind.row An optional vector of the row indices that are used. If not specified, all rows are used. Don't use negative indices. ind.col An optional vector of the column indices that are used. If not specified, all columns are used. Don't use negative indices. ncores Number of cores used. Default doesn't use parallelism. You may use nb_cores. block.size Maximum number of columns read at once. Default uses block_size. center Vector of same length of ind.col to subtract from columns of X. scale Vector of same length of ind.col to divide from columns of X. x A 'double' FBM or a matrix. y A 'double' FBM or a matrix.

X^T \cdot A.

## Matrix parallelization

Large matrix computations are made block-wise and won't be parallelized in order to not have to reduce the size of these blocks. Instead, you may use Microsoft R Open or OpenBLAS in order to accelerate these block matrix computations. You can also control the number of cores used with bigparallelr::set_blas_ncores().

## Examples

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X <- big_attachExtdata() n <- nrow(X) m <- ncol(X) A <- matrix(0, n, 10); A[] <- rnorm(length(A)) test <- big_cprodMat(X, A) true <- crossprod(X[], A) all.equal(test, true) X2 <- big_copy(X, type = "double") all.equal(crossprod(X2, A), true) # subsetting ind.row <- sample(n, n/2) ind.col <- sample(m, m/2) tryCatch(test2 <- big_cprodMat(X, A, ind.row, ind.col), error = function(e) print(e)) # returns an error. You need to use the subset of A: test2 <- big_cprodMat(X, A[ind.row, ], ind.row, ind.col) true2 <- crossprod(X[ind.row, ind.col], A[ind.row, ]) all.equal(test2, true2) 

bigstatsr documentation built on April 5, 2021, 5:08 p.m.