涉及指针的矩阵乘法 [英] Matrix multiplication involving pointers
本文介绍了涉及指针的矩阵乘法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该如何将矩阵C(常数)与A相乘并将结果存储在B中?有关当前案例,请参见代码片段.
how to do i multiply matrix C(constant) and A and store the results in B? See the snippet code for the case at hand.
tom.cpp file
void tom::multiply(void* btr)
{
short* A =(short*)btr;
int j,i;
short C[4][4]={1,1,1,1,2,1,-1,-2,1,-1,-1,1,1,-2,2,-1};
short B[4][4];
推荐答案
您知道:
B<small>ik</small> = C<small>ij</small> * A<small>jk</small>
在重复索引 j 上加上和.
那(可能)翻译为:
With sum on the repeated index j.
That''s (probably) translates to:
for (i=0; i<4; i++)
for (k=0; k<4; k++)
for (j=0; j<4; j++)
B[i][k] = C[i][j] * A[j*4+k]
就您而言.
:)
in your case.
:)
这篇关于涉及指针的矩阵乘法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文