Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 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 N X N

All values will be integers

File format:

N (dimension of the matrix)

number1 number2 number3 ...

For help on matrix multiplication see http://www.purplemath.com/modules/mtrxmult.htm.

Restrictions: You cannot expand the compressed matrices to do the multiplication. Again the whole point is to save space.

In the examples on the next page the values are shown on 1 line to save space

Cat mat1.txt 4 1 2 3 17 4 51 25 6 31 9

cat mat2.txt 4 25 73 -4 -17 -99 81 -88 11 12 10

./triMatMult.out mat1.txt mat2.txt

25 -125 191 13 -396 885 510 66 382 90

This is equivalent to doing C = A * B where:

A = 1 2 3 17 0 4 51 25 0 0 6 31 0 0 0 9

B = 25 73 -4 -17 0 -99 81 -88 0 0 11 12 0 0 0 10

C = 25 -125 191 13 0 -396 885 510 0 0 66 382 0 0 0 90

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

what are the provisions in the absence of Partnership Deed?

Answered: 1 week ago

Question

1. What is called precipitation?

Answered: 1 week ago

Question

1.what is dew ?

Answered: 1 week ago