What is Chain Matrix Multiplication?
I am trying to understand what is a chain matrix multiplication and how it is different from a regular multiplication. I ha开发者_开发百科ve checked several sourcers yet all seem to be very academically explained for me to understand.
I guess it is a form of dynamic programming algorithm to achieve the operation in an optimised way but I didn't go any further.
Thanks
Chain multiplication is just series of multiplications. A * B * C * D . Originally it has nothing about programming and dynamic programming. But there is nice rule (associative law) A * (B * C) = (A * B) * C, but the computational cost of these expressions are different. So there is a task of optimal brackets distribution. it was intro. now read wiki.
Matrix Chain Multiplication is a Problem that can be solved by Dynamic Programming approach, It requires proper parenthesized Matrices in order to multiply given matrices with minimum number of multiplications. Example
M1 = 12 x 20
M2 = 20 x 15
M3 = 15 x 30
There are two ways to solve this problem, depends from where you start to multiply your matrices.
1). ((M1 x M2) x M3)
2). (M1 x (M2 x M3))
First one requires only 3,600 + 5,400 = 9,000 multiplications.
Second solution requires 9,000 + 7,200 = 16,200 multiplications.
Here we will choose first over second because it needs less number of multiplications.
Your program must be able to tell the user how to parenthesize matrices so that it minimizes multiplications(Optimization Problem)
精彩评论