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% (1 review)
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...
-
Consider the n-queens problem using the efficient incremental formulation given on page 72. Explain why the state space has at least 3n! states and estimate the largest n for which exhaustive...
-
According to the Supreme Court decision in Quill Corp. v. North Dakota, a state may not require a retailer with no physical presence in the state to collect and remit sales tax on sales made in the...
-
The accountant of Latifa Shoe Co. has compiled the following information from the companys records as a basis for an income statement for the year ended December 31, 2014. Rent revenue...
-
Criticism of the World Bank is generally on a diverse range of issues but they generally centre around concern about the approaches adopted by the World Bank in formulating their policies, and the...
-
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...
-
Write each repeating decimal first as a geometric series and then as a fraction (a ratio of two integers). 0.1 = 0.111...
-
Compare and contrast your favorite and least favorite commercials from this year's Super Bowl 2023 (if you are not watching the game you can just watch them later on YouTube). Using the topics and...
-
Compare and contrast between make-to-stock and make-to-order systems. In your comparison, why does each system require different types of contracts? What are the advantages and disadvantages of each...
-
Compare and contrast management skills needed by a manager at two different levels of an agency. Give examples of the various skills needed at each level of management. Please include at least one...
-
Compare and contrast risks and assumptions. What is the core difference? Why is it important to identify both?
-
Compare and contrast the traditional method of performance appraisal with the more modern method of performance appraisal.
-
Barnard Corp. will pay a dividend of $3.05 next year. The company has stated that it will maintain a constant growth rate of 5 percent a year forever. If you want a 15 percent rate of return, how...
-
Thalina Mineral Works is one of the worlds leading producers of cultured pearls. The companys condensed statement of cash flows for the years 20182020 follows. Required Comment on Thalina Mineral...
-
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.
-
Eriksons theory suggests that developmental changes occur throughout our lives in eight distinct stages. The stages emerge in a fixed pattern and are similar for all people. Erikson argued that each...
-
A petroleum engineering firm manager is planning on investing in land so the firm would be able to expand its drilling operations. By investing in the drilling operation, the firm will realize a...
-
An investor buys a 20-year Bbb-rated corporate bond with a nominal annual rate of return of 10%. The average inflation rate is expected to be 2%. The default risk premium is expected to be 5% and the...
Study smarter with the SolutionInn App