TheMatrixMultiplicationOrderProblem矩阵相乘的序问题.ppt

TheMatrixMultiplicationOrderProblem矩阵相乘的序问题.ppt

ID:57646233

大小:151.50 KB

页数:31页

时间:2020-08-30

TheMatrixMultiplicationOrderProblem矩阵相乘的序问题.ppt_第1页
TheMatrixMultiplicationOrderProblem矩阵相乘的序问题.ppt_第2页
TheMatrixMultiplicationOrderProblem矩阵相乘的序问题.ppt_第3页
TheMatrixMultiplicationOrderProblem矩阵相乘的序问题.ppt_第4页
TheMatrixMultiplicationOrderProblem矩阵相乘的序问题.ppt_第5页
资源描述:

《TheMatrixMultiplicationOrderProblem矩阵相乘的序问题.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、TheMatrixMultiplicationOrderProblem (矩阵相乘的序问题)例Multiplyarrayswiththesizeshown:A1×A2×A3×A430×11×4040×1010×25Matrixmultiplicationisassociative满足结合律A(BC)=(AB)CHowmanymultiplicationsaredone?((A1A2)A3)A430·1·40+30·40·10+30·10·25=20,700A1(A2(A3A4))40·10·25+1·40·25+30·40·25=1

2、1,750(A1A2)(A3A4)30·1·40+40·10·25+30·40·25=41,200A1((A2A3)A4)1·40·10+1·10·25+30·1·25=1,400Forthegeneralproblem,supposethedimensionsofAiaredi-1×difor1≤i≤nA1×A2×…×And0×d1d1×d2dn-1×dnThereare(n-1)!kindsofassociationHowshouldwecomputeandwhatistheminimumcostofdoingso?Thecos

3、tisthenumberofelement-wisemultiplication.AGreedyAttemptFirst,choosethemultiplicationwithminimumcost.DeterminethedimensionsofthematricesinthemodifiedmatrixchainChoosethemultiplicationwithminimumcost.Andsoon.Thisstrategymayfailstobeoptimalforsomesequencesofthreematrices?

4、Example:A1×A2×A35×44×55×6Typically,dynamicprogrammingalgorithmsaremoreexpensivethangreedyalgorithm,sotheyareusedwhennogreedystrategycanbefoundthatdeliverstheoptimalsolution.ARecursiveAlgorithmSoppose,afterchoosingafirstmultiplication,sayatpositioniinthesequence,werecur

5、sivelysolvetheremainingproblemoptimally.Wedothisforeachithatrepresentsavalidchoice,andfinallyselecttheithatgivesthelowestcombinedcost.BacktrackingAftertryingonecompletechoicesequence,thealgorithmbacktrackstothepointbeforethemostrecentchoiceandtriesanalternative;whenalt

6、ernativesareexhaustedatthispoint,itbacktrackstoanearlierpointandtriesalternativesthere,andcontinuesuntilallalternativeareexhausted.d0,d1,d2…,dnareinanarraydim.Theinitialindexsequenceis0,…,nAllindexesofthesequence,exceptthefirstandthelast,specifymultiplicationoperators,

7、aswell.Aftermakingafirstchoiceofmultiplicationi,theindexsequencefortheremainingproblemis0,…,i-1,i+1,…,nAllindexesofthesequence,exceptthefirstandthelast,specifymultiplicationoperators,aswell.B=Ai×Ai+1A1×…×Ai-1×B×Ai+2×…×And0×d1di-2×di-1di-1×di+1di+1×di+2Assumetheindexseq

8、uenceitselfisstoredinazero-basedarrayseq,andlenisthelengthofseq.mmTry1(dim,len,seq)if(len<3)bestCost=0;elsebestCost=∞

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。