The input file The input file contains the size of the square matrix N (N-by-N) in...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The input file The input file contains the size of the square matrix N (N-by-N) in the first line. The subsequent lines each hold one matrix element. For example for the following matrix: 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 the data is stored in the input file as follows: 3 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 You may assume only valid input files are passed to your program. Three test input files are supplied with your homework assignment. You may use them for reference. You only need to submit your source file that contains the main function along with all other functions defined. You should use the format in the frame.txt file. For every function, the required information is provided as comments. The function declaration is also provided in the frame.txt file. The resulting matrix should be written to the output file in the format just like the input file. Memory Leak Detection Since you will use dynamic memory allocation, it is important not to have any memory leaks. You can do this check in the final steps of your homework. Type the following command when you want to execute your program and Valgrind checks your executable to find any memory leaks. You should have 0 memory leaks to pass this check. You should not have any memory leaks if you properly free the memory you allocated during your program. prompt $ valgrind --leak-check-full ./ The students that use an Apple computer as their local machine, can use the leaks command in their terminal. More information is provided here. On submitty, we use valgrind to grade their homeworks. Homework Specifications In this homework, you will write a program to perform 2-D square matrix multiplication. For the first operand (matrix), your program reads a matrix of doubles from a file. The name of the file is provided on the command line (i.e. argv[1]). For the second operand (matrix), your program should generate the swapped version of the first matrix. The swap matrix operation is implemented as follows: the ith column is exchanged/swapped with the contents of the i+2 column. So, column 0 is swapped with column 2 and column 1 is swapped with column 3 and so on until all columns are swapped up to column N - 1 for an N-by-N matrix. The following figure shows one example input and its swapped version. The Input Matrix: /******** START of 2-D Matrix **** 1.000000 5.000000 9.000000 2.000000 6.000000 10.000000 14.000000 3.000000 7.000000 11.000000 15.000000 13.000000 /******** END of 2-D Matrix ******** Output of Swap Matrix /******** START of 2-D Matrix ***** 3.000000 4.000000 7.000000 8.000000 11.000000 12.000000 15.000000 16.000000 /******** END of 2-D Matrix ****** 1.000000 5.000000 9.000000 13.000000 4.000000 8.000000 12.000000 16.000000 2.000000 6.000000 10.000000 14.000000 *** ****** The input file The input file contains the size of the square matrix N (N-by-N) in the first line. The subsequent lines each hold one matrix element. For example for the following matrix: 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 the data is stored in the input file as follows: 3 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 You may assume only valid input files are passed to your program. Three test input files are supplied with your homework assignment. You may use them for reference. You only need to submit your source file that contains the main function along with all other functions defined. You should use the format in the frame.txt file. For every function, the required information is provided as comments. The function declaration is also provided in the frame.txt file. The resulting matrix should be written to the output file in the format just like the input file. Memory Leak Detection Since you will use dynamic memory allocation, it is important not to have any memory leaks. You can do this check in the final steps of your homework. Type the following command when you want to execute your program and Valgrind checks your executable to find any memory leaks. You should have 0 memory leaks to pass this check. You should not have any memory leaks if you properly free the memory you allocated during your program. prompt $ valgrind --leak-check-full ./ The students that use an Apple computer as their local machine, can use the leaks command in their terminal. More information is provided here. On submitty, we use valgrind to grade their homeworks. Homework Specifications In this homework, you will write a program to perform 2-D square matrix multiplication. For the first operand (matrix), your program reads a matrix of doubles from a file. The name of the file is provided on the command line (i.e. argv[1]). For the second operand (matrix), your program should generate the swapped version of the first matrix. The swap matrix operation is implemented as follows: the ith column is exchanged/swapped with the contents of the i+2 column. So, column 0 is swapped with column 2 and column 1 is swapped with column 3 and so on until all columns are swapped up to column N - 1 for an N-by-N matrix. The following figure shows one example input and its swapped version. The Input Matrix: /******** START of 2-D Matrix **** 1.000000 5.000000 9.000000 2.000000 6.000000 10.000000 14.000000 3.000000 7.000000 11.000000 15.000000 13.000000 /******** END of 2-D Matrix ******** Output of Swap Matrix /******** START of 2-D Matrix ***** 3.000000 4.000000 7.000000 8.000000 11.000000 12.000000 15.000000 16.000000 /******** END of 2-D Matrix ****** 1.000000 5.000000 9.000000 13.000000 4.000000 8.000000 12.000000 16.000000 2.000000 6.000000 10.000000 14.000000 *** ******
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these algorithms questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
(a) Explain how a limit worth may be tended to at run-time, both in a syntaxtree middle person and in collected code. What is the importance word "settled" already? [3 marks] (b) Give a model program...
-
Adrian Webb bought 618 bricks to build a barbecue pit, paying $185.40. Find the cost per brick. (HINT: Cost per brick means the cost for one brick.) The cost per brick is s (Round to nearest hundidth)
-
Presented below are financial statements (except cash flows) for two not-for-profit organizations. Neither organization has any permanently restricted net assets. A. Calculate the following ratios: ...
-
The CAPM provides required returns for individual securities or portfolios. What uses can you see for such a model?
-
What is the difference between an ectotherm and an endotherm? Which vertebrates are ectotherms, and which are endotherms?
-
Selected account balances before adjustment for Intuit Realty at November 30, 2014, the end of the current year, are shown below. Data needed for year-end adjustments are as follows: a. Supplies on...
-
2. Amongst the 14 Bravais Lattices there are four belonging to the Orthorhombic crystal system: Primitive (P, simple), Face Centered (F), Body Centered (I) and Base Centered (C). In contrast to this...
-
1. Bare cost and total cost (incl. O&P) of formwork for spread footings (20 pts, specify which lines (or index) in RSMeans data are used) 2. Bare cost and total cost of reinforcement for spread...
-
Select all of the following statements that are true regarding the financial crisis: Credit agencies such as Moodys tried their best to rate the mortgage-backed securities properly during the 2008...
-
Consider the politics of law enforcement related to terrorism and homeland security. What do you believe the future holds for law enforcement in these areas? How do you see policing changing? Should...
-
Explore one Senge's system law that impacts you. For this law,please do the following: Describe a Sengesystem law that impacts your performance. Discuss how it impacts your performance. Provide three...
-
Based on the law to guarantee equal employment opportunities: What does the law establish? What sanctions apply to anyone who violates the Law mentioned above?
-
In this discussion, you will attach the graph and equation of your two limaons (one sine and one cosine) with the same a and b values ( a does not have to equal b ). Your graphs may be cardioids or...
-
What is the 10 plus 2 rule . How does it affect the companys global transportation operations?
-
Evaluate I = SFnds uhere f= z+ xj+ 3yjk and in is eunit vector. s is j- 3yjk and n is unit vecter. S is the sueface of cylinder xy=9 included between z= o to Z=S. in first octant
-
On the basis of the details of the following fixed asset account, indicate the items to be reported on the statement of cashflows: ACCOUNT Land ACCOUNT NO. Balance Date Item Debit Credit Debit Credit...
-
Mike purchases a heavy-duty truck (5-year class recovery property) for his delivery service on April 30, 2012. The truck is not considered a passenger automobile for purposes of the listed property...
-
Sally and Charles Heck received the following dividends and interest during 2012: Assuming the Hecks file a joint tax return, complete Schedule B of Form 1040 (on page 2-33) for them for the 2012 tax...
-
Frank Willingham has the following transactions during the year: Sale of office equipment on March 15 that cost $20,000 when purchased on July 1, 2010. Frank has claimed $5,000 in depreciation and...
-
We can make a static measurement to deduce the spring constant to use in the model. If a \(61 \mathrm{~kg}\) woman stands on a low wall with her full weight on the ball of one foot and the heel free...
-
If, during a stride, the stretch causes her center of mass to lower by \(10 \mathrm{~mm}\), what is the stored energy? A. \(3.0 \mathrm{~J}\) B. \(6.0 \mathrm{~J}\) C. \(9.0 \mathrm{~J}\) D. \(12...
-
A \(1.00 \mathrm{~kg}\) block is attached to a horizontal spring with spring INT constant \(2500 \mathrm{~N} / \mathrm{m}\). The block is at rest on a frictionless surface. A \(10.0 \mathrm{~g}\)...
Study smarter with the SolutionInn App