Write a function to add two sparse matrices as represented in Section 12.2. 12.2 Matrix Representations Some
Question:
Write a function to add two sparse matrices as represented in Section 12.2.
Transcribed Image Text:
12.2 Matrix Representations Some applications must represent a large, two-dimensional matrix where many of the elements have a value of zero. One example is the lower triangular matrix that results from solving systems of simultaneous equations. A lower triangular matrix stores zero values at positions [r, c] such that r < c, as shown in Figure 12.6(a). Thus, the upper-right triangle of the matrix is always zero. Another example is the representation of undirected graphs in an adjacency matrix (see Project 11.2). Because all edges between Vertices i and j go in both directions, there is no need to store both. Instead we can just store one edge going from the higher-indexed vertex to the lower-indexed vertex. In this case, only the lower triangle of the matrix can have non-zero values. We can take advantage of this fact to save space. Instead of storing n(n+1)/2 pieces of information in an n x n array, it would save space to use a list of length n(n+1)/2. This is only practical if some means can be found to locate within the list the element that would correspond to position [r, c] in the original matrix. To derive an equation to do this computation, note that row 0 of the matrix has one non-zero value, row 1 has two non-zero values, and so on. Thus, row r is preceded by r rows with a total of 1k = (r + r)/2 non-zero elements. Adding c to reach the cth position in the rth row yields the following equation to convert position [r, c] in the original matrix to the correct position in the list. matrix[r, c] = list [(r +r)/2+c]. A similar equation can be used to store an upper triangular matrix, that is, a matrix with zero values at positions [r, c] such that r>c, as shown in Figure 12.6(b). For an n x n upper triangular matrix, the equation would be matrix[r, c] = list[rn - (r +r)/2+c].
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 100% (2 reviews)
The text in the image describes a way to represent matrices specifically lower and upper triangular matrices using a list to save space This form of representation is particularly useful for sparse ma...View the full answer
Answered By
Qurat Ul Ain
Successful writing is about matching great style with top content. As an experienced freelance writer specialising in article writing and ghostwriting, I can provide you with that perfect combination, adapted to suit your needs.
I have written articles on subjects including history, management, and finance. Much of my work is ghost-writing, so I am used to adapting to someone else's preferred style and tone. I have post-graduate qualifications in history, teaching, and social science, as well as a management diploma, and so am well equipped to research and write in these areas.
4.80+
265+ Reviews
421+ Question Solved
Related Book For
Practical Introduction To Data Structures And Algorithm Analysis Java Edition
ISBN: 9780136609117
1st Edition
Authors: Clifford A. Shaffer
Question Posted:
Students also viewed these Computer science questions
-
Program to add two sparse matrices and print the input matrices and result in normal matrix form.
-
Consider the following structure declaration for a linked list in C: struct node { int data; struct node* tail; }; typedef struct node Node; We represent linked lists as pointers to Node structs....
-
Can hydrogen or deuterium emit an particle? Explain.
-
An ideal gas having a constant specific heat undergoes a reversible polytropic expansion with exponent, n 1.4. If the gas is carbon dioxide will the heat transfer for this process be...
-
Develop sales promotions for each of the following: a. A nearby regional shopping center. b. A 30-year old restaurant. c. An discount online furniture retailer.
-
Define HRs role in organizational design and structure. (pp. 294296)
-
Manasee Atre is an award-winning innovator who makes educational toys for preschool children. Manasees company, which she whimsically named Pumpkin Patch, makes plastic pieces that can be assembled...
-
Problem 3-33 (LO 3-3, 3-4, 3-6) On January 1, 2018. Brooks Corporation exchanged $1,029,000 fair-value consideration for all of the outstanding voting stock of Chandler, Inc. At the acquisition date,...
-
Write memory manager allocation and deallocation routines for the situation where all requests and releases follow a last-requested, first-released (stack) order.
-
Write a function to transpose a sparse matrix as represented in Section 12.2. 12.2 Matrix Representations Some applications must represent a large, two-dimensional matrix where many of the elements...
-
Consider the continuous random variables that follow. Give the probability distribution (uniform, normal, or exponential) that is likely to best approximate the distribution of the random variable:...
-
Find the expected value of buying the extended warranty. The expected value of buying the extended warranty is . A new flat - screen TV comes with a 1 - year warranty wh ich completely covers any...
-
An Olympic runner is coming to visit your school. You have been told that a world class race has two stages. In the first stage, the runner accelerates at a constant rate until he reaches maximum...
-
Question 3(15 marks) An investor holds 100,000 units of a bond whose features per bond are summarized in the following table. She wishes to be hedged against a rise in interest rates. Maturity Coupon...
-
12. In a professional cycling race, competitors (the "peloton") begin the race by riding 45.0 km north, then the road turns west by 37 for the next 50.0 km, before turning due west for the final 35.0...
-
Whateva Ltd uses a flexible budget and standard costs to aid planning and control of its machining manufacturing operations. The costing system for manufacturing has two direct cost categories...
-
Air at 257C and 400 kPa is contained in a pistoncylinder device. The air expands adiabatically until the pressure is 100 kPa. Determine the mass of air needed to produce maximum work of 1000 kJ....
-
The water in tank A is at 270 F with quality of 10% and mass 1 lbm. It is connected to a piston/cylinder holding constant pressure of 40 psia initially with 1 lbm water at 700 F. The valve is opened,...
-
Can you configure your browser to open multiple simultaneous connections to a Web site? What are the advantages and disadvantages of having a large number of simultaneous TCP connections?
-
We have seen that Internet TCP sockets treat the data being sent as a byte stream but UDP sockets recognize message boundaries. What are one advantage arid one disadvantage of byte-oriented API...
-
What is the Apache Web server? How much does it cost? What functional ity does it currently have? You may want to look at Wikipedia to answer this question.
-
Be prepared to explain the texts comprehensive To illustrate the issues related to interest capitalization, assume that on November 1, 2016, Shalla Company contracted Pfeifer Construction Co. to...
-
On April 1, 2020. Indigo Company received a condemnation award of $473,000 cash as compensation for the forced sale of the company's land and building, which stood in the path of a new state highway....
-
The market price of a stock is $24.55 and it is expected to pay a dividend of $1.44 next year. The required rate of return is 11.23%. What is the expected growth rate of the dividend? Submit Answer...
Study smarter with the SolutionInn App