DAA EXP 4.pdf - Student Name: Sivaramakrishnan Subramanian...

This preview shows page 1 - 3 out of 9 pages.

Student Name: Sivaramakrishnan SubramanianUID: 20BCG1014Branch: BE CSE G&GSection/Group: 20BCG1014Semester: 4thSemesterSubject Name: Design and Algorithms Lab.1. Aim/Overview of the practical:WS4Write a program to implement Strassen's matrix multiplication2.Code:#include <algorithm>#include <iostream>#include <bits/stdc++.h>using namespace std;int nextpowerof2(int k){return pow(2, int(ceil(log2(k))));}void display(vector< vector<int>> &matrix, int m, int n){for (int i = 0; i < m; i++){for (int j = 0; j < n; j++){if (j != 0){cout << "\t";}cout << matrix[i][j];}
cout << endl;}}void add(vector<vector<int>> &A, vector<vector<int>> &B, vector<vector<int>> &C, int size){int i, j;for (i = 0; i < size; i++){for (j = 0; j < size; j++){C[i][j] = A[i][j] + B[i][j];}}}void sub(vector<vector<int>> &A, vector<vector<int>> &B, vector<vector<int>> &C, int size){int i, j;for (i = 0; i < size; i++){for (j = 0; j < size; j++){C[i][j] = A[i][j] - B[i][j];}}}void Strassen_algorithmA(vector<vector<int>> &A, vector<vector<int>> &B, vector<vector<int>> &C, int size){//base caseif (size == 1){C[0][0] = A[0][0] * B[0][0];return;

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 9 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
professor_unknown
Tags
AirTrain Newark, Howard Staunton, Rover P6, Algorithms Lab, Sivaramakrishnan Subramanian

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture