Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am writing a program in c++. this is the skeleton I have so far: #include #include using namespace std; int main() { int n1,

I am writing a program in c++.

image text in transcribed

image text in transcribed

this is the skeleton I have so far:

#include #include

using namespace std;

int main() { int n1, n2;

ifstream inFile1, inFile2; inFile1.open ("mat1.txt"); inFile2.open ("mat2.txt"); // cout

int x = n1; int i=0; int size = 0; for(i=1;i

int* file1contents = new int[n1*n1]; for(int i=0; i> file1contents[i*n1 + j]; } }<1>

inFile2 >> n2; int* file2contents = new int[n2*n2]; for(int i=0; i> file2contents[i*n2 + j]; } }<2>

// Print file contents to check it worked cout

cout

delete [] file1contents; delete [] file2contents;

inFile1.close(); inFile2.close(); return 0; }

An upper triangular matrix is a special type of matrix where all the values below the main diagonal are 0. In order to save space we can store this matrix without the zeros. For example 1 2 3 0 4 5 0 0 6 Would be stored as 1 2 3 4 5 6 We would also like to be able to work with these matrices in their compressed format, again to save space. Write a C++ program called, triMatMult.cpp,that accepts as arguments two files that contain these compressed upper triangular matrices. The program should multiply the two matrices together and then display the resulting compressed matrix in its compressed form. The names of the files will be given on the command line All matrices will be square, ie NXN All values will be integers File format o N (dimension of the matrix) o number 1 o number 2 o number 3 For help on matrix multiplication see h urplemath.com/modules/mtrkmult.htm Restrictions: You cannot expand the compressed matrices to do the multiplication. If you do this you will receive no credit for this portion of the assignment. Again the whole point is to save Space

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

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

How would you describe your typical day at work?

Answered: 1 week ago

Question

2. Write two or three of your greatest weaknesses.

Answered: 1 week ago