代写 C++ C math Files to submit: triMatMult.cpp

Files to submit: triMatMult.cpp
Time it took Matthew to complete: ?
• All programs must compile without warnings when using the -Wall and -Werror options
• Submit only the files requested
◦ Do NOT submit folders or compressed files such as .zip, .rar, .tar, .targz, etc • If submitting in a group on Grade Scope please make sure to mark your partner.
◦ Only one of you has to submit there
• Your program must match the output exactly to receive credit.
◦ Make sure that all prompts and output match mine exactly.
◦ Easiest way to do this is to copy and paste them
• All input will be valid unless stated otherwise
• Print all real numbers to two decimal places unless otherwise stated
• The examples provided in the prompts do not represent all possible input you can receive.
• All inputs in the examples in the prompt are underlined
◦ You don’t have to make anything underlined it is just there to help you differentiate between what you are supposed to print and what is being given to your program
• If you have questions please post them on Piazza
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
123
Would be stored as 123456
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 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. If you
do this you will receive no credit for this portion of the assignment. 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
0
4
5
0
0
6

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=
B=
C=
25
73
-4
-17
0
-99
81
-88
0
0
11
12
0
0
0
10
1
2
3
17
0
4
51
25
0
0
6
31
0
0
0
9
25
-125
191
13
0
-396
885
510
0
0
66
382
0
0
0
90