Learn R Programming

rpc (version 2.0.3)

XXt.compute: XXt Computation

Description

For an input matrix X, This function computes UU' = tcrossprod(U) where U = scale(X) in a memory efficient way.

Usage

XXt.compute(
  X,
  meanX = NULL,
  varX = NULL,
  ncores = 4,
  check = TRUE,
  chunksize = 1000
)

Value

a nrow(X) x nrow(X) dense symmetric matrix.

Arguments

X

The input matrix of type `matrix' or `dgCMatrix'. No need to center or scale X as that would be done implicitly.

meanX

Vector of column means of X. Will be computed if not provided.

varX

Vector of column variances of X. Will be computed if not provided.

ncores

the number of cores to be used. Default is 1.

check

check for zero variances.

chunksize

When using openmp parallelization, this would be the chunk size under a dynamic scheduling.

Author

Somak Dutta

Maintainer: Somak Dutta <somakd@iastate.edu>

Examples

Run this code
require("Matrix")
set.seed(123)
x <- rsparsematrix(100,100,density = 0.3)
norm(XXt.compute(x) - tcrossprod(scale(x))) # (4.783951e-13 on my machine)

Run the code above in your browser using DataLab