Performs efficient matrix multiplication using block-based algorithms. The function supports various input combinations (matrix-matrix, matrix-vector, vector-vector) and provides options for parallel processing and block-based computation.
Integer. Block size for computation. If NULL, uses maximum allowed block size.
paral
Logical. If TRUE, enables parallel computation. Default is FALSE.
byBlocks
Logical. If TRUE (default), forces block-based computation for large matrices. Can be set to FALSE to disable blocking.
threads
Integer. Number of threads for parallel computation. If NULL, uses half of available threads or maximum allowed threads.
4 Value
Matrix or vector containing the result of A * B.
5 Details
This function implements block-based matrix multiplication algorithms optimized for cache efficiency and memory usage. Key features: - Input combinations supported: - Matrix-matrix multiplication - Matrix-vector multiplication (both left and right) - Vector-vector multiplication - Performance optimizations: - Block-based computation for cache efficiency - Parallel processing for large matrices - Automatic block size selection - Memory-efficient implementation
The function automatically selects the appropriate multiplication method based on input types and sizes. For large matrices (>2.25e+08 elements), block-based computation is used by default.
---title: "bdblockMult"subtitle: "bdblockMult"---<span class="category-badge other">OTHER</span>## DescriptionPerforms efficient matrix multiplication using block-based algorithms. The functionsupports various input combinations (matrix-matrix, matrix-vector, vector-vector)and provides options for parallel processing and block-based computation.## Usage```rbdblockMult(A, B, block_size =NULL, paral =NULL, byBlocks =TRUE, threads =NULL)```## Arguments::: {.param-table}| Parameter | Description ||-----------|-------------||`A`| Matrix or vector. First input operand. ||`B`| Matrix or vector. Second input operand. ||`block_size`| Integer. Block size for computation. If NULL, uses maximum allowed block size. ||`paral`| Logical. If TRUE, enables parallel computation. Default is FALSE. ||`byBlocks`| Logical. If TRUE (default), forces block-based computation for large matrices. Can be set to FALSE to disable blocking. ||`threads`| Integer. Number of threads for parallel computation. If NULL, uses half of available threads or maximum allowed threads. |:::## Value::: {.return-value}Matrix or vector containing the result of A * B.:::## DetailsThis function implements block-based matrix multiplication algorithms optimizedfor cache efficiency and memory usage. Key features:- Input combinations supported: - Matrix-matrix multiplication - Matrix-vector multiplication (both left and right) - Vector-vector multiplication- Performance optimizations: - Block-based computation for cache efficiency - Parallel processing for large matrices - Automatic block size selection - Memory-efficient implementationThe function automatically selects the appropriate multiplication method basedon input types and sizes. For large matrices (>2.25e+08 elements), block-basedcomputation is used by default.## Examples```{r}#| eval: false#| code-fold: showlibrary(BigDataStatMeth)# Matrix-matrix multiplicationN <-2500M <-400nc <-4set.seed(555)mat <-matrix(rnorm(N*M, mean=0, sd=10), N, M)# Parallel block multiplicationresult <-bdblockMult(mat, mat,paral =TRUE,threads = nc)# Matrix-vector multiplicationvec <-rnorm(M)result_mv <-bdblockMult(mat, vec,paral =TRUE,threads = nc)```## See Also::: {.see-also}- [bdblockSum](../blockwise_ops/bdblockSum.html) for block-based matrix addition- [bdblockSubstract](../blockwise_ops/bdblockSubstract.html) for block-based matrix subtraction:::