arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2410.21050cs.DScs.CCcs.MS
收藏

面向可变精度算术的具有O(N^2log_2N)计算复杂度的矩阵乘矩阵算法

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

Maciej Paszyński

AI总结:

本文提出一种基于可变精度算术的矩阵乘矩阵算法,通过将8次分块乘法减少为4次并引入取整与取模运算,使计算复杂度降至O(N^2log_2N),并用MATLAB vpa仿真器验证了其可行性。

摘要:

我们证明,在假设处理器具备可变精度算术能力的前提下,可以以O(N^2log_2N)的计算复杂度计算矩阵乘矩阵乘法。我们将标准的矩阵乘矩阵乘法 \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} 替换为 \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}+εA_{12})(B_{11}+1/εB_{21}) & (A_{11}+εA_{12})(B_{12}+1/εB_{22}) \\\\ (A_{21}+εA_{22})(B_{11}+1/εB_{21}) &(A_{21}+εA_{22})(B_{12}+1/εB_{22})\end{bmatrix} \Bigr\rfloor \\% \frac{1}ε,其中\lfloor \rfloor表示向下取整,\\%表示取模运算符。我们将分块矩阵乘矩阵乘法的次数从8次减少到4次,保持加法次数为4次,并额外引入4次分块矩阵乘以ε或\frac{1}ε的乘法,以及4次向下取整和4次取模运算。对于两个大小为N×N的矩阵,所得计算复杂度可由递归方程T(N)=4(N/2)^2(矩阵乘以ε和1/ε的乘法)加上4(N/2)^2(两个矩阵的加法)加上2N^2(向下取整和取模)加上4T(N/2)(四次递归调用)估计为O(N^2log_2N)。这些矩阵分块乘以数的运算规模为O((N/2)^2)。我们还给出了使用vpa可变精度算术仿真器的MATLAB代码,该仿真器可以用(4log_2N+1)N^2次vpa运算来乘大小为N×N的矩阵。该仿真器使用O(N)位数字来运行我们的算法。

英文摘要:

We show that assuming the availability of the processor with variable precision arithmetic, we can compute matrix-by-matrix multiplications in $O(N^2log_2N)$ computational complexity. We replace the standard matrix-by-matrix multiplications $\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 $\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}+εA_{12})(B_{11}+1/εB_{21}) & (A_{11}+εA_{12})(B_{12}+1/εB_{22}) \\ (A_{21}+εA_{22})(B_{11}+1/εB_{21}) &(A_{21}+εA_{22})(B_{12}+1/εB_{22})\end{bmatrix} \Bigr\rfloor \% \frac{1}ε$ 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 $ε$ or $\frac{1}ε$, and 4 floor and 4 modulo operations. The resulting computational complexity for two matrices of size $N\times N$ can be estimated from recursive equation $T(N)=4(N/2)^2$ (multiplication of a matrix by $ε$ and $1/ε$) plus $4(N/2)^2$ (additions of two matrices) plus $2N^2$ (floor and modulo) plus $4T(N/2)$ (four recursive calls) as $O(N^2log_2N)$. These multiplications of blocks of a matrix by number scales like $O((N/2)^2)$. We also present a MATLAB code using \emph{vpa} variable precision arithmetic emulator that can multiply matrices of size $N\times N$ using $(4log_2N+1)N^2$ vpa operations. This emulator uses $O(N)$ digits to run our algorithm.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑