9 views

Uploaded by fallckor

- Project Management
- Basic Concepts in Matlab
- Syllabus12
- Matrix Multiplication in C
- LaTeX Cheat Sheet
- Groups -Questions
- PMP Questions
- Workbook Analytics
- SM1 Wks3-8
- lesson plan project 2014
- How to Multiply Matrices
- MTH 331_Matrices 1
- Model Real Reduct
- Introduction to R
- r05012301 Computer Programming for Biotechnologists
- 401-IntroR
- amsldoc
- 4_384
- 01
- CS-E3190_lect03 (2).pdf

You are on page 1of 11

Sibel KIRMIZIGL

Suppose we want to multiply two matrices of size N x N: for example A x B = C.

C21 = a21b11 + a22b21 C22 = a21b12 + a22b22

2x2 matrix multiplication can be accomplished in 8 multiplication.(2log28 =23)

void matrix_mult (){ for (i = 1; i <= N; i++) { for (j = 1; j <= N; j++) { compute Ci,j; } }}

algorithm

Time analysis

Ci , j ai ,k bk , j

k 1

Thus T ( N ) c cN 3 O( N 3 )

i 1 j 1 k 1

Strassen showed that 2x2 matrix multiplication can be accomplished in 7 multiplication and 18 additions or subtractions. .(2log27 =22.807) This reduce can be done by Divide and Conquer Approach.

Divide-and-Conquer

Divide-and conquer is a general algorithm design paradigm:

Divide: divide the input data S in two or more disjoint subsets S1, S2, Recur: solve the subproblems recursively Conquer: combine the solutions for S1, S2, , into a solution for S

The base case for the recursion are subproblems of constant size Analysis can be done using recurrence equations

A

A0 A2 A1 A3

B0 B2

B

B1 B3

=

=

R

A0B0+A1B2 A2B0+A3B2 A0B1+A1B3 A2B1+A3B3

A

a0

B

b0

= =

R

a0 b0

P1 = (A11+ A22)(B11+B22) P2 = (A21 + A22) * B11 P3 = A11 * (B12 - B22) P4 = A22 * (B21 - B11) P5 = (A11 + A12) * B22 P6 = (A21 - A11) * (B11 + B12) P7 = (A12 - A22) * (B21 + B22)

Comparison

C11 = P1 + P4 - P5 + P7 = (A11+ A22)(B11+B22) + A22 * (B21 - B11) - (A11 + A12) * B22+ (A12 - A22) * (B21 + B22) = A11 B11 + A11 B22 + A22 B11 + A22 B22 + A22 B21 A22 B11 A11 B22 -A12 B22 + A12 B21 + A12 B22 A22 B21 A22 B22 = A11 B11 + A12 B21

Strassen Algorithm

void matmul(int *A, int *B, int *R, int n) { if (n == 1) { (*R) += (*A) * (*B); } else { matmul(A, B, R, n/4); matmul(A, B+(n/4), R+(n/4), n/4); matmul(A+2*(n/4), B, R+2*(n/4), n/4); matmul(A+2*(n/4), B+(n/4), R+3*(n/4), n/4); matmul(A+(n/4), B+2*(n/4), R, n/4); matmul(A+(n/4), B+3*(n/4), R+(n/4), n/4); matmul(A+3*(n/4), B+2*(n/4), R+2*(n/4), n/4); matmul(A+3*(n/4), B+3*(n/4), R+3*(n/4), n/4); }

Time Analysis

- Project ManagementUploaded byAnnyanna Andra
- Basic Concepts in MatlabUploaded byapi-3833675
- Syllabus12Uploaded byVjPratz
- Matrix Multiplication in CUploaded byuserscrybd
- LaTeX Cheat SheetUploaded byTanuj Bhojwani
- Groups -QuestionsUploaded byMihai Catana
- PMP QuestionsUploaded byosama_ah
- Workbook AnalyticsUploaded byHeather
- SM1 Wks3-8Uploaded byErin Gallagher
- lesson plan project 2014Uploaded byapi-284227922
- How to Multiply MatricesUploaded bycontactrn
- MTH 331_Matrices 1Uploaded bykairi99
- Model Real ReductUploaded byandrenr
- Introduction to RUploaded byHuGo HuGo HuGo
- r05012301 Computer Programming for BiotechnologistsUploaded bySrinivasa Rao G
- 401-IntroRUploaded bymkrg23
- amsldocUploaded byMonsit Tanasittikosol
- 4_384Uploaded byUbiquitous Computing and Communication Journal
- 01Uploaded byJunaid Ahmad
- CS-E3190_lect03 (2).pdfUploaded byYuri Shukhrov
- Lec9p1Uploaded byMayank San
- courseoutline134_summer2017 (1)Uploaded bysarah
- Malaysia Lects Ops Pres O-HsUploaded byleella_889605
- 123352-337792-1-PBUploaded bySameh Lotfy
- lesson plan math obrien 2Uploaded byapi-391628725
- 02_The-Basics_Part1.pdfUploaded byamila_vithanage
- WEEK 5 pathwayUploaded byclaudia
- Lecture 1510Uploaded bynils4586
- funinthesunmathtaskUploaded byapi-294592109
- Math Forum_ Ask Dr. Math FAQ_ Negative Times a NegativeUploaded byBruno Martins

- Decomposition TechniquesUploaded byHarkamal Singh
- adaUploaded byrh1234567
- MCS-031 Block 1 Unit 1 Elementary AlgorithmicsUploaded bydhabalia_kirit
- HW1Uploaded byRafael Santillan
- Recurrence TreeUploaded byamukhopadhyay
- Binary Search AlgorithmUploaded bySalman Ahmed
- Substitution MethodUploaded byamukhopadhyay
- StrassenUploaded byamukhopadhyay
- Divide-and-conquer-closestPair [Autosaved].pptUploaded bybhargavpatel24
- StrassenUploaded byfallckor
- Mergesort is a Perfect Example of a Successful Application of the Divide and ConquerUploaded byPradiptapb
- Strassen matrix multiplicationUploaded bysgtrajkuppu123