English

Matrix-by-matrix multiplication algorithm with $O(N^2log_2N)$ computational complexity for variable precision arithmetic

Data Structures and Algorithms 2025-08-19 v2 Computational Complexity Mathematical Software

Abstract

We show that assuming the availability of the processor with variable precision arithmetic, we can compute matrix-by-matrix multiplications in O(N2log2N)O(N^2log_2N) computational complexity. We replace the standard matrix-by-matrix multiplications [A11A12A21A22][B11B12B21B22]=[A11B11+A12B21A11B12+A12B22A21B11+A22B21A21B12+A22B22]\begin{bmatrix} A_{11} & A_{12} \\ A_{21} & A_{22}\end{bmatrix}\begin{bmatrix} B_{11} & B_{12} \\ B_{21} & B_{22}\end{bmatrix}=\begin{bmatrix} A_{11}B_{11}+A_{12}B_{21} & A_{11}B_{12}+A_{12}B_{22} \\ A_{21}B_{11}+A_{22}B_{21} & A_{21}B_{12}+A_{22}B_{22}\end{bmatrix} by [A11A12A21A22][B11B12B21B22]=[(A11+ϵA12)(B11+1/ϵB21)(A11+ϵA12)(B12+1/ϵB22)(A21+ϵA22)(B11+1/ϵB21)(A21+ϵA22)(B12+1/ϵB22)]%1ϵ\begin{bmatrix} A_{11} & A_{12} \\ A_{21} & A_{22}\end{bmatrix}\begin{bmatrix} B_{11} & B_{12} \\ B_{21} & B_{22}\end{bmatrix}=\Bigl\lfloor\begin{bmatrix} (A_{11}+\epsilon A_{12})(B_{11}+1/{\epsilon}B_{21}) & (A_{11}+\epsilon A_{12})(B_{12}+1/{\epsilon}B_{22}) \\ (A_{21}+\epsilon A_{22})(B_{11}+1/{\epsilon}B_{21}) &(A_{21}+\epsilon A_{22})(B_{12}+1/{\epsilon}B_{22})\end{bmatrix} \Bigr\rfloor \% \frac{1}{\epsilon} where \lfloor \rfloor denotes the floor, and %\% denotes the modulo operators. We reduce the number of block matrix-by-matrix multiplications from 8 to 4, keeping the number of additions equal to 4, and additionally introducing 4 multiplications of a block matrices by ϵ\epsilon or 1ϵ\frac{1}{\epsilon}, and 4 floor and 4 modulo operations. The resulting computational complexity for two matrices of size N×NN\times N can be estimated from recursive equation T(N)=4(N/2)2T(N)=4(N/2)^2 (multiplication of a matrix by ϵ\epsilon and 1/ϵ1/\epsilon) plus 4(N/2)24(N/2)^2 (additions of two matrices) plus 2N22N^2 (floor and modulo) plus 4T(N/2)4T(N/2) (four recursive calls) as O(N2log2N)O(N^2log_2N). These multiplications of blocks of a matrix by number scales like O((N/2)2)O((N/2)^2). We also present a MATLAB code using \emph{vpa} variable precision arithmetic emulator that can multiply matrices of size N×NN\times N using (4log2N+1)N2(4log_2N+1)N^2 vpa operations. This emulator uses O(N)O(N) digits to run our algorithm.

Keywords

Cite

@article{arxiv.2410.21050,
  title  = {Matrix-by-matrix multiplication algorithm with $O(N^2log_2N)$ computational complexity for variable precision arithmetic},
  author = {Maciej Paszyński},
  journal= {arXiv preprint arXiv:2410.21050},
  year   = {2025}
}

Comments

20 pages, 2 tables, 1 figure