Attribution Non-Commercial (BY-NC)

129 views

Attribution Non-Commercial (BY-NC)

- C++ Project For Class 12(Cricket) Final
- Solution Chapter6
- DSPA Solution Manual Chap 5 - kk parhi
- BHSEC+Mathematics+2009
- Customer Creation API Sample Code
- math autobiography
- Tips and Tricks Working With 3-D-C Products
- E-Gurukul
- ABAQUSXYPlots
- SOALAN BENGKEL ADDMATH
- Xam Schedule
- C++ pgms
- adat
- 3dframe
- Assignment 1
- in2post
- Codigo Fuente Actividad Tres
- Mdi form
- Lab de Actuadors
- App Enhance

You are on page 1of 12

C = AB is an n by p matrix.

• C = AB can be computed in O(nmp) time, using traditional matrix

multiplication.

• Matrix Multiplication is associative, so I can do the multiplication in

several different orders.

Example:

• A1 is 10 by 100 matrix

• A2 is 100 by 5 matrix

• A3 is 5 by 50 matrix

• A4 is 50 by 1 matrix

• A1A2A3A4 is a 10 by 1 matrix

Example

• A1 is 10 by 100 matrix

• A2 is 100 by 5 matrix

• A3 is 5 by 50 matrix

• A4 is 50 by 1 matrix

• A1A2A3A4 is a 10 by 1 matrix

• (A1(A2(A3A4)))

• ((A1A2)(A3A4))

• (((A1A2)A3)A4)

• ((A1(A2A3))A4)

• (A1((A2A3)A4))

Let Aij = Ai · · · Aj

Example

A4 is 50 by 1 matrix, A1A2A3A4 is a 10 by 1 matrix.

• (A1(A2(A3A4)))

– A34 = A3A4 , 250 mults, result is 5 by 1

– A24 = A2A34 , 500 mults, result is 100 by 1

– A14 = A1A24 , 1000 mults, result is 10 by 1

– Total is 1750

• ((A1A2)(A3A4))

– A12 = A1A2 , 5000 mults, result is 10 by 5

– A34 = A3A4 , 250 mults, result is 5 by 1

– A14 = A12A34) , 50 mults, result is 10 by 1

– Total is 5300

• (((A1A2)A3)A4)

– A12 = A1A2 , 5000 mults, result is 10 by 5

– A13 = A12A3 , 2500 mults, result is 10 by 50

– A14 = A13A4 , 500 mults, results is 10 by 1

– Total is 8000

Example

A4 is 50 by 1 matrix, A1A2A3A4 is a 10 by 1 matrix.

• ((A1(A2A3))A4)

– A23 = A2A3 , 25000 mults, result is 100 by 50

– A13 = A1A23 , 50000 mults, result is 10 by 50

– A14 = A13A4 , 500 mults, results is 10 by

– Total is 75500

• (A1((A2A3)A4))

– A23 = A2A3 , 25000 mults, result is 100 by 50

– A24 = A23A4 , 5000 mults, result is 100 by 1

– A14 = A1A24 , 1000 mults, result is 10 by 1

– Total is 31000

compute the minimum?

One approach

• a single matrix, or

• a product of two fully parenthesized matrices, surrounded by parenthe-

ses

need to pick the parenthesization that corresponds to the best ordering.

One approach

• a single matrix, or

• a product of two fully parenthesized matrices, surrounded by parenthe-

ses

need to pick the parenthesization that corresponds to the best ordering.

Pn−1

k=1 P (k)P (n − k) if n ≥ 2

P (n) =

1 if n = 1

P (n) = Ω(4n/n3/2).

Use dynamic programming

2. Recursively define the value of an optimal solution

3. Compute the value of an optimal solution bottom-up

4. Construct an optimal solution from the computed information

then the optimal solution consists of solving A1i and Ai+1,n optimally

and then combining the solutions.

Proof

((A1A2 · · · Ai)(Ai+1 · · · An))

then the optimal solution consists of solving A1i and Ai+1,n optimally

and then combining the solutions.

Proof: Consider an optimal algorithm that does not solve A1i optimally.

Let x be the number of multiplications it does to solve A1i , y be the

number of multiplications it does to solve Ai+1,n , and z be the number of

multiplications it does in the final step. The total number of multiplications

is therefore

x + y + z.

But since it is not solving A1i optimally, there is a way to solve A1i

using x0 < x multiplications. If we used this optimal algorithm instead of

our current one for A1i , we would do

x0 + y + z < x + y + z

multiplications and therefore have a better algorithm, contradicting the

fact that our algorithms is optimal.

Proof

Proof: Consider an optimal algorithm that does not solve A1i optimally.

Let x be the number of multiplications it does to solve A1i , y be the

number of multiplications it does to solve Ai+1,n , and z be the number of

multiplications it does in the final step. The total number of multiplications

is therefore

x + y + z.

But since it is not solving A1i optimally, there is a way to solve A1i

using x0 < x multiplications. If we used this optimal algorithm instead of

our current one for A1i , we would do

x0 + y + z < x + y + z

multiplications and therefore have a better algorithm, contradicting the

fact that our algorithms is optimal.

lems, assume we didn’t solve the subproblems optimally, then we could

just replace them with an optimal subproblem solution and have a better

solution.

Recursive solution

unique subproblems are there?

Recursive solution

unique subproblems are there?

O(n2) subproblems!

Notation

• Let Ai be pi−1 by pi .

• Let m[i, j] be the cost of computing Aij

0 if i = j ,

m[i, j] =

min {m[i, k] + m[k + 1, j] + pi−1pk pj } if i < j

i≤k<j

Direct recursion on this does not work! We must use the fact that there

are at most O(n2) different calls. What is the order?

The final code

Matrix-Chain-Order(p)

1 n ← length[p] − 1

2 for i ← 1 to n

3 do m[i, i] ← 0

4 for l ← 2 to n l is the chain length.

5 do for i ← 1 to n − l + 1

6 do j ← i + l − 1

7 m[i, j] ← ∞

8 for k ← i to j − 1

9 do q ← m[i, k] + m[k + 1, j] + pi−1pk pj

10 if q < m[i, j]

11 then m[i, j] ← q

12 s[i, j] ← k

13 return m and s

- C++ Project For Class 12(Cricket) FinalUploaded bySon Goku
- Solution Chapter6Uploaded byBunga Safhira Wirata
- DSPA Solution Manual Chap 5 - kk parhiUploaded byNESEGA
- BHSEC+Mathematics+2009Uploaded bysawanchhetri
- Customer Creation API Sample CodeUploaded byeanuradha
- math autobiographyUploaded byapi-353969193
- Tips and Tricks Working With 3-D-C ProductsUploaded by009neeraj
- E-GurukulUploaded byE-gurukul
- ABAQUSXYPlotsUploaded bymadhu77
- Xam ScheduleUploaded byRatnesh Kumar Verma
- C++ pgmsUploaded byPriyanka Shetty
- Assignment 1Uploaded byPrince Singh
- SOALAN BENGKEL ADDMATHUploaded byzilasamsmel
- adatUploaded byBagas Oktavian
- in2postUploaded byHarsha Subbarayappa
- Lab de ActuadorsUploaded by3boomer
- 3dframeUploaded bygheinba
- Codigo Fuente Actividad TresUploaded bycarloscolunga
- App EnhanceUploaded bysurajit6349
- Mdi formUploaded byMandeep Kamboj
- MCQUploaded byZohaib Khan
- MS3LOG07Uploaded byParag Aggarwal
- phpmPX9gyUploaded byContinuing Education at the University of Vermont
- LogUploaded byAlan Basilio
- Mid Year Exam F2 2016Uploaded bynurfarhana.sappar
- blog_ajaxUploaded byAlanna Smith
- Arduino ProgrammingUploaded byAndresRengifo
- comandos 3Uploaded byElías Alexander
- BTACHUploaded bymanu333
- 2018 ICpEP CpE Challenge Mechanics ProgrammingUploaded byCha Figueroa

- Wear Debris Analysis ASHWIN THOTTUMKARA FULL PPTUploaded byASHWIN THOTTUMKARA
- Seminar Format for B TechUploaded byASHWIN THOTTUMKARA
- STUDY OF MODELLING AND DEVELOPMENT ENVIRONMENT FOR VIRTUAL MANUFACTURING SYSTEMS- ASHWIN THOTTUMKARA FULL REPORTUploaded byASHWIN THOTTUMKARA
- Pre-Installation of Offshore Pipe Lines ASHWIN THOTTUKARAUploaded byASHWIN THOTTUMKARA
- UTILITY FOG ASHWIN THOTTUMKARA, REPORT- COMPLETEUploaded byASHWIN THOTTUMKARA
- LOOP HEAT PIPES-ASHWIN THOTTUMKARA FULL PPTUploaded byASHWIN THOTTUMKARA
- ACTIVE WHEELS/ HUB MOTORS ASHWIN THOTTUMKARA FULL PPTUploaded byASHWIN THOTTUMKARA
- Marketing Mix ASHWIN THOTTUMKARA FULL PPTUploaded byASHWIN THOTTUMKARA
- UTILITY FOG ASHWIN THOTTUMKARA CertificateUploaded byASHWIN THOTTUMKARA
- Automation in Automobile Manual Shift- ASHWIN THOTTUMKARAUploaded byASHWIN THOTTUMKARA
- ALUMINIUM GREEN SUPPLY CHAIN ASHWIN THOTTUMKARA FULL PPTUploaded byASHWIN THOTTUMKARA
- Fully Automatic Ultrasonic Flaw Detectior- ASHWIN THOTTUMKARAUploaded byASHWIN THOTTUMKARA
- UTILITY FOG ASHWIN THOTTUMKARA, AKNOLEDGEMENTUploaded byASHWIN THOTTUMKARA
- UTILITY FOG ASHWIN THOTTUMKARA TitleUploaded byASHWIN THOTTUMKARA
- Automatic Weld Flaw DetectorUploaded byASHWIN THOTTUMKARA

- Alos Leon and Vives - Finance and Stochastics.pdfUploaded byChun Ming Jeffy Tam
- The TexacoUOP HF Alkylation Additive Technology Aerosolization Reduction EffectsUploaded byKen Comey
- Chapter 11 Differential Amplifier CircuitsUploaded byNayr JT
- Computational Aeroacoustics An Overview.pdfUploaded byVenu Madhav
- Benjamin, Quinn, Su - Phased Tilings and Generalized Fibonacci IdentitiesUploaded byiitforum
- Circuit TheoryUploaded byavi713331
- Siddhanta Shiromani Ch 9 TranslatedUploaded bygirija
- SPSW Practice Assessment Book Muddle StoneUploaded byMelita Rudo Ncube Zhuwarara
- delphimobiledevelopmentwhitepaper180613.pdfUploaded byhsminao
- Project Quality Management[1]Uploaded bytkp2009
- Quantum Gravity, Generalized Theory of Gravitation, And Super String Theory-Based Unification - Mintz,PerlmutterUploaded byGopal Kumar
- 01 Fall 2013 Final SolutionsUploaded bydai_dai
- LAB BCA E AND E (kud)Uploaded byNaveen Bhat
- pgfplot : a latex utilityUploaded byapathak
- Tercera Tarea 20162 EjerciciosUploaded byNicolás Tovar
- daubechiesUploaded byNguyen Anh
- Lecture Set 3Uploaded byPavan Deep
- 07- Regresi NonlinearUploaded bySuseno Bayu Setyo Adi
- Cooling and Heating Load Calculations - R&AC Lecture 32Uploaded byUpendra Bajpai
- alternative to practical.pdfUploaded bySara Emad
- ARL-TR-4901Uploaded byBarce Lamasia Catalan
- Kok Et Al, 2018. Integrative Taxonomy of the Gymnophthalmid Lizard Neusticurus Rudis Boulenger,Uploaded byKevin Jaico
- A Mathematical Model of Tonal FunctionUploaded bydundun
- MB0048 Operations ResearchUploaded bySaagar Karande
- Dyna ConvUploaded bysertini
- Digital Image ProcessingUploaded byAbhishek Rai
- Relationships in geometryUploaded byMome Gul Hussain
- Jager et al. - 2014 - A Student Introduction to Solar Energy.pdfUploaded byjorgre
- 205-agueroUploaded byFreeway Smile
- Chemistry 1st Year Test (3)Uploaded byRashid Jalal

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.