Click here to Skip to main content
16,006,605 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
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];
Posted

1 solution

You know:
B<small>ik</small> = C<small>ij</small> * A<small>jk</small>


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.

:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900