【文件属性】:
文件名称:Ruby实现的矩阵连乘算法
文件大小:29KB
文件格式:PDF
更新时间:2021-01-02 15:14:35
array ruby 矩阵
动态规划解决矩阵连乘问题,随机产生矩阵序列,输出形如((A1(A2A3))(A4A5))的结果。
代码:
#encoding: utf-8
=begin
author: xu jin, 4100213
date: Oct 28, 2012
MatrixChain
to find an optimum order by using MatrixChain algorithm
example output:
The given array is:[30, 35, 15, 5, 10, 20, 25]
The optimum order is:((A1(A2A3))((A4A5)A6))
The