Matrix chain multiplication: Difference between revisions

Content deleted Content added
Eoraptor (talk | contribs)
mNo edit summary
Eoraptor (talk | contribs)
mNo edit summary
Line 15: Line 15:
;Task
;Task


Write a function which, given a list of the successive dimension of matrices A1, A2... An, of arbitrary length, returns the optimal way to compute the matrix product, and the total cost. The list does not duplicate shared dimensions: for the previous example of matrices A,B,C, one will only pass the list [5,6,3,1]. Hence, a product of n matrices is represented by a list of n+1 dimensions.
Write a function which, given a list of the successive dimensions of matrices A1, A2... An, of arbitrary length, returns the optimal way to compute the matrix product, and the total cost. The list does not duplicate shared dimensions: for the previous example of matrices A,B,C, one will only pass the list [5,6,3,1]. Hence, a product of n matrices is represented by a list of n+1 dimensions.


Try this function on the following two lists:
Try this function on the following two lists: