矩阵乘法中的转置矩阵 [英] Transpose matrix in matrix multiplication
问题描述
我从Stack Overflow中找到了我需要的东西,现在我有一个问题,这个函数有什么好处
static void transpose_matrix()
{
int i,j;
for(i = 0; i< SIZE; i ++)
for(j = 0; j< SIZE; j ++)
b [i] [j] = b_to_trans [j] [i] ;
}
以及为什么要使用这个条件?谁有人向我解释?请。
if(i> = SIZE / 2)a [i] [j] = 2.0;
b_to_trans [i] [j] = 1.0; //这个数组在特定的
if(j> = SIZE / 2)b [i] [j] = 2.0;
我的尝试:
我通过此链接找到我需要的内容 c - MPI中的矩阵乘法 - 堆栈溢出 [ ^ ]
在标题中,您询问矩阵乘法,而在您提出的关于转置矩阵的问题中。转置矩阵只是为了切换行和列:
TransposeA [i] [j] = A [j] [i]矩阵乘法有点麻烦,因为您需要确保第一个矩阵中的列在第二个矩阵中具有相同数量的行。它只是执行第一个矩阵中的列和第二个matix中的行的点积。
结果[i] [j] = \sum_ {k} {A(i,k)\ cdot B(k,j)}
但是,如果计算速度很重要,那么实现一个数学库肯定会更好:
英特尔®MathKernel Library(英特尔®MKL)|英特尔®软件 [ ^ ] >
或使用你的GPU:
性能 - 为什么MATLAB在矩阵乘法中如此之快? - 堆栈溢出 [ ^ ]
I find what I need from Stack Overflow and now I have a question,what is the benefit of this function
static void transpose_matrix()
{
int i, j;
for(i = 0; i<SIZE; i++)
for(j = 0; j<SIZE;j++)
b[i][j] = b_to_trans[j][i];
}
and why useing this conditions ? can anyone explain to me? please.
if(i >= SIZE/2) a[i][j] = 2.0;
b_to_trans[i][j] = 1.0; //this array in specific
if(j >= SIZE/2) b[i][j] = 2.0;
What I have tried:
I find what I need from this link c - Matrix Multiplication in MPI - Stack Overflow[^]
In the header, you ask about matrix multiplication, while in the question you ask about transposing a matrix. Transposing a matrix is just to switch the rows and columns:
TransposeA[i][j]=A[j][i]Matrix multiplication is a bit more cumbersome as you need to make sure that the columns in the first matrix have an equal number of rows in the second matrix. That it is just to perform a dot product of the column in the first matrix and the row in the second matix.
Result[i][j] = \sum_{k}{A(i,k) \cdot B(k,j)}
However, If the speed of calculation is of importance it would certainly be better to implement a math library like:
Intel® Math Kernel Library (Intel® MKL) | Intel® Software[^]
or use your GPU:
performance - Why is MATLAB so fast in matrix multiplication? - Stack Overflow[^]
这篇关于矩阵乘法中的转置矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!