Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this project you'll perform a comparison of time-efficiencies of generic matrix multiplication algorithms. for each of of the following types of matrices: 1. Regular

In this project you'll perform a comparison of time-efficiencies of generic matrix multiplication algorithms. for each of of the following types of matrices:

1. Regular matrix 2. Upper triangular matrix 3. Lower triangular matrix 4. Diagonal matrix 5. Tri-diagonal matrix

Part 1 (75 points):

Explore and implement the matrix multiplication for each matrix type (you must use computationally efficient algorithms for each type that should avoid multiplying entries which will produce a 0 as result). For each type of matrix, identify the basic operation(s) and then compute C(n), the number of times the basic operation(s) is executed (n is the number of elements in the matrix). Then display the values of C(n) for multiplying each type of matrix in a Table with columns indicating the type of matrix. Limit yourself to n = 10^2.

Part 2 (25 points):

Based on the values of C(n) computed in Part 1, identify O(C(n)) for multiplying each type of matrix that is the closest estimate to the running time of the algorithm.

PLEASE THE CODE BELOW MUST BE ABLE TO PERFORM THE INSTRUCTIONS ABOVE SO PLESAS HELP ME OUT.

#include using namespace std;

int main() { // Regular Matrix Multication int aRMat[][3] = { { 1,2,3 }, { 4,5,6 } }; int bRMat[][3] = { { 0,2 }, { 1,3 }, { 0,0 } }; int regResult[2][2];

for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { regResult[i][j] = 0; for (int k = 0; k < 3; k++) { regResult[i][j] += aRMat[i][k] * bRMat[k][j]; } } } for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { cout << regResult[i][j] << " "; } cout << " "; }

cout << " ";

//--------------------------------------------- // Upper Triangular Matrix Multication int aUTMat[][3] = { { 1,2,3 }, { 0,1,2 }, { 0,0,1 } }; int bUTMat[][3] = { { 1,2,3 }, { 0,1,2 }, { 0,0,2 } }; int upTResult[3][3];

for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { upTResult[i][j] = 0; for (int k = 0; k < 3; k++) { upTResult[i][j] += aUTMat[i][k] * bUTMat[k][j]; } } } for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { cout << upTResult[i][j] << " "; } cout << " "; }

cout << " "; //------------------------------------------------ // Lower Triangular Matrix Multication int aLTMat[][3] = { { 1,0,0 }, { 3,1,0 }, { 3,2,1 } }; int bLTMat[][3] = { { 1,0,0 }, { 3,1,0 }, { 4,2,1 } }; int lowTResult[3][3];

for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { upTResult[i][j] = 0; for (int k = 0; k < 3; k++) { lowTResult[i][j] += aLTMat[i][k] * bLTMat[k][j]; } } } for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { cout << lowTResult[i][j] << " "; } cout << " "; }

cout << " ";

//------------------------------------------------ // Diagonal Matrix Multication int adMat[][3] = { { 3,0,0 }, { 0,2,0 }, { 0,0,5 } }; int bdMat[][3] = { { 2,0,0 }, { 0,4,0 }, { 0,0,3 } }; int dResult[3][3];

for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { dResult[i][j] = 0; for (int k = 0; k < 3; k++) { dResult[i][j] += adMat[i][k] * bdMat[k][j]; } } } for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { cout << dResult[i][j] << " "; } cout << " "; }

cout << " "; //------------------------------------------------ // Tri-Diagonal Matrix Multication int aTDMat[][4] = { { 2,3,0,0 }, { 1,4,6,0 }, { 0,2,6,9 }, { 0,0,3,8 } }; int bTDMat[][4] = { { 1,8,0,0 }, { 5,2,9,0 }, { 0,6,3,10 }, { 0,0,7,4 } }; int TDResult[4][4];

for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { TDResult[i][j] = 0; for (int k = 0; k < 4; k++) { TDResult[i][j] += aTDMat[i][k] * bTDMat[k][j]; } } } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { cout << TDResult[i][j] << " "; } cout << " "; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago