Learn R Programming

bigstatsr (version 0.6.2)

big_prodMat: Product with a matrix

Description

Product between a Filebacked Big Matrix and a matrix.

Usage

big_prodMat(X, A.col, ind.row = rows_along(X), ind.col = cols_along(X),
  ncores = 1, block.size = block_size(nrow(X), ncores))

Arguments

X

A FBM.

A.col

A matrix with length(ind.col) 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.

Value

\(X \cdot A\).

Examples

Run this code
# NOT RUN {
X <- big_attachExtdata()
n <- nrow(X)
m <- ncol(X)
A <- matrix(0, m, 10); A[] <- rnorm(length(A))

test <- big_prodMat(X, A)
true <- X[] %*% A
all.equal(test, true)

# subsetting
ind.row <- sample(n, n/2)
ind.col <- sample(m, m/2)

tryCatch(test2 <- big_prodMat(X, A, ind.row, ind.col),
         error = function(e) print(e))
# returns an error. You need to use the subset of A:
test2 <- big_prodMat(X, A[ind.col, ], ind.row, ind.col)
true2 <- X[ind.row, ind.col] %*% A[ind.col, ]
all.equal(test2, true2)

# }

Run the code above in your browser using DataLab