Question: In great need for a simple c++ program to implement the manipulation of square matrix ,including add ,multipy,and transpose(by the method of fast transpose,as the

In great need for a simple c++ program to implement the manipulation of square matrix ,including add ,multipy,and transpose(by the method of fast transpose,as the pic shows)

input will be a file named input_data.txt

input format:

The first column has an integer n (1

Output Format: Please output square matrix A and square B add, multiply and the transpose table and transpose results(as the pic shows) of matrix A, with the break line to separate the results.

Input Example 3 1 0 9 -1 -2 -3 1 9 10 1 0 0 0 1 0 0 0 1

Output Example 2 0 9 -1 -1 -3 1 9 11

1 0 9 -1 -2 -3 1 9 10

r: 3 2 3 s: 1 4 6

1 -1 1 0 -2 9 9 -3 10

THX for ur help:)

In great need for a simple c++ program to implement the manipulation

Transpose: We can verify that fastTranspose works correctly from the nd the observation that the starting point of row i, i >1 of the tran- rwTermsi1+ starting Posli-1J, where rowTermsli-1] is the number of and startingPosli-1] is the starting point of row i-1. The first two spose matrix is elements in row i-1 Pos he values for rowTerms, the third for loop carries out the computa s, and the last for loop places the triples into the transpose matrix o four loops determine the computing time of fast Transpose. The bodies of th I, and numTerms times, respectively tion mputing time of fastTranspose. The b loops are executed numCols, num Since the statements the the algorithm is +elements umber of elements is of the order columns rows. This time equals that of t numTerms, numCols - 1 ents within the loops require only constant time, the computing time for O(columns + elements). The time becomes O(columns rows) when the he two- dimensional array representation, although fastTranspose has a larger constant factor However, when the number of elements is sufficiently small compared to the maxim um lumns rows, fastTranspose is much faster. Thus, in this representation we save and space. This was not true of transpose since the numer of elements is usu- lly greater than max columns, rows) and columns elements is always at least ns rows. In addition, the constant factor for transpose is bigger than that found in colum the two-dimensional array representation. However, transp fastTranspose since the latter function must allocate space for the rowTerms and starting arrays. We can reduce this space to one array if we put the starting positions into the space used by the row terms as we calculate each starting position. f we try the algorithm on the sparse matrix of Figure 2.5(a), then after the execu- n of the third for loop, the values of rowTerms and startin gPos are [0] [1 12] 13] [4] [5] row! e rms = startingPos = r of entries in row i of the transpose is contained in rowTermsIil. The starting ition for row i of the transpose is held by starting Posltil

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!