This function performs matrix multiplication of two matrices (`mat1` and `mat2`)
using minibatching to manage memory usage and parallel processing to speed up
computation. It is particularly useful for large matrices where full multiplication
would otherwise be computationally intensive or memory prohibitive.
Usage
matrixMultiply(mat1, mat2, minibatch = 5000, ncores = 1)
Arguments
- mat1
A matrix with dimensions (m x n).
- mat2
A matrix with dimensions (n x p).
- minibatch
The number of columns from `mat2` to process in each minibatch. Default is 5000.
- ncores
The number of cores to use for parallel processing. Default is 1 (no parallel processing).
Value
A matrix with dimensions (m x p) representing the product of `mat1` and `mat2`.
Examples
# Example usage:
mat1 <- matrix(runif(1000), nrow=100, ncol=10)
mat2 <- matrix(runif(2000), nrow=10, ncol=200)
result <- matrixMultiply(mat1, mat2, minibatch=100, ncores=2)