Product between a Filebacked Big Matrix and a matrix.
big_prodMat(
X,
A.col,
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 FBM,matrix
%*%(x, y)
# S4 method for matrix,FBM
%*%(x, y)
An object of class FBM.
A matrix with length(ind.col)
rows.
An optional vector of the row indices that are used. If not specified, all rows are used. Don't use negative indices.
An optional vector of the column indices that are used. If not specified, all columns are used. Don't use negative indices.
Number of cores used. Default doesn't use parallelism. You may use nb_cores.
Maximum number of columns read at once. Default uses block_size.
Vector of same length of ind.col
to subtract from columns of X
.
Vector of same length of ind.col
to divide from columns of X
.
A 'double' FBM or a matrix.
A 'double' FBM or a matrix.
\(X \cdot A\).
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 can use
the MKL
or OpenBLAS in order to accelerate these block matrix computations.
You can control the number of cores used by these optimized matrix libraries
with bigparallelr::set_blas_ncores()
.
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)
#> [1] TRUE
X2 <- big_copy(X, type = "double")
all.equal(X2 %*% A, true)
#> [1] 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))
#> <simpleError: Incompatibility between dimensions.
#> 'ind.col' and 'rows_along(A.col)' should have the same length.>
# 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)
#> [1] TRUE