![]() MATRIX-CHAIN-MULTIPLICATION (a1,…,an) for L=1 to n do S = 0 for d=1 to n do for L=1 to n-d do R = L+d S = 1 for k=L to R-1 tmp = S+S+aL-1.ak. Input: Output: Objective: a chain of matrices to be multiplied a parenthesizing of the chain minimize number of steps needed for the multiplication Heart of the solution: S = the minimum number of steps required to multiply matrices from the L-th to the R-th Input: Output: Objective: a chain of matrices to be multiplied a parenthesizing of the chain minimize number of steps needed for the multiplication Heart of the solution: ![]() ![]() Input: Output: Objective: a chain of matrices to be multiplied a parenthesizing of the chain minimize number of steps needed for the multiplication Example: Input: Output: Objective: a chain of matrices to be multiplied a parenthesizing of the chain minimize number of steps needed for the multiplication Matrix multiplication: A of size m x n, B of size n x p How many steps to compute A.B ? When we did this, we broke our original problem up into two smaller. Multiplying the first two matrices first (left) introduces a small matrix, allowing for more efficient calculation. It’s much faster to multiply A B first, then multiply the result by C. Input: Output: Objective: a chain of matrices to be multiplied a parenthesizing of the chain minimize number of steps needed for the multiplication Matrix Chain Multiplication is the optimization problem. The first multiplication generates a 10 × 8 matrix, which is then multiplied by A.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |