0
$\begingroup$

Possible Duplicate:
Matrix multiplications (obtaining values)

Hi,

I have a final tomorrow and it includes multiplying matrices (getting a table of values) but i do not understand how he is getting some of the numbers

something like this

suppose the matrices are

 A3X4  B4X5    C5x7    D7X2

in the results table he has

          A    B     C       D
    A     0    60    165     134
    B           0    140     110
    C                0       70
    D                        0

     A     B      C      D
A    A     A*B    A*B*C  A*B*C*D
B          B      B*C    B*C*D
C                 C      C*D
D                        D

How is he getting 164 unders C for example? I know how he is getting the twi dimentional ones like for instance the 140 under C would be BC which is 4X5X7 = 140 but I have no idea how he is getting for the AB*C = 165

Thank you

  • 0
    It looks to me as if the table contains operation counts. For example A*B requires 3*5 dot products, each requiring 4 ops and so A*B requires 60 ops in total. I reckon the table is showing the least op count way to compute A*B*C*D, ie A*(B*(C*D); 70 ops for C*D (5x7 * 7x2) an additional 40 to compute B*(C*D) (4x5 * 5x2) and finally an additional 24 to compute A*(B*(C*D)) (3x4 * 4x2).2011-05-13

1 Answers 1

0

If you're multiplying E = A*B*C*D, then E ought to be a 3x2 matrix, right?

And the rule for matrix multiplication is simple:

Given W(m,n), U(m, p), and V(p, n) then W = U*V

for (int i = 0; i < m; ++i)
{
    for (int j = 0; j < n; ++j)
    {
        double sum = 0.0;
        for (int k = 0; k < p; k++)
        {
            sum += u[i, k]*v{k, j];   
        }
        w[i, j] = sum;
    }
}
  • 0
    I know what you say, I know that 3 matrices that are for example A3X4, B4X5, C5X7, would give me a 3X7, but thats not what i need... what i need to know is the number of multiplications..i think thats what that value means,,, in example above i need to figure out how to get A*B*C = 165 considering A = 3X4, B=4x5, C=5X72011-05-01
  • 0
    Yes, you have to calculate A*B, then multiply that by C, then multiply that by D.2011-05-01
  • 0
    Ok so, i did A*B = 3X5 = 15 A*B*C = 3X7 = 21 A*B*C*D = 3X2 if i add them up i get 42, so not good, then i tried A*B = 3X4X5 = 60 and A*B*C = 3X5X7 = 105 when i add them i get 165 but now i cant get 110 :(2011-05-02