Question: * What I have so far for Problem #3 ]: #include struct Matrix { double *X; // Matrix elements pointer int n_rows, n_columns; // Rows

 * What I have so far for Problem #3]: #include struct

* What I have so far for Problem #3]:

#include

struct Matrix { double *X; // Matrix elements pointer int n_rows, n_columns; // Rows and column dimensions };

void DefineMatrix(Matrix &A, int rows, int columns) { A.n_rows = rows; A.n_columns = columns; A.X = (double *)calloc(rows * columns, sizeof(double)); }

void DisplayMatrix(Matrix A) { for (int i = 0; i

void SpecifyMatrixElements(Matrix &A) { std::cout > A.X[i + k* A.n_rows]; } } }

void TransposeMatrix(Matrix A, Matrix &B){ for (int i = 0; i

int main() { Matrix A,B; int A_rows, A_columns, B_rows, B_columns; std::cout > A_rows; std::cout > A_columns; DefineMatrix(A, A_rows, A_columns); SpecifyMatrixElements(A); DisplayMatrix(A); std::cout

// SpecifyMatrixElements(A); DisplayMatrix(B); // DefineMatrix(B, A_columns, A_rows); // SpecifyMatrixElements(B); // DisplayMatrix(B); }

* While the code does end up working as you can see in the console window below, the transposed matrix is generated incorrectly which makes me believe I need to fix the void transposematrix function. Please let me know how I can fix this.

sh -c make -s ./main Please enter the number of rows for Matrix A 2 Please enter the number of columns for Matrix A 3 Specify elements for Matrix A Enter Matrix element A[0][0] : 1 Enter Matrix element A[0][1] : 2 Enter Matrix element A[0][2] : 3 Enter Matrix element A[1][0] : 4 Enter Matrix element A[1][1] : 5 Enter Matrix element A[1][2] : 6 1 2 3 4 5 6 Matrix B (A Transpose): 1 3 5 2 4 6

* What I have so far for Problem #4]:

#include #include

using namespace std;

vector> reverse(vector> matrix) { vector> C(matrix.size(), vector(matrix[0].size())); for (int i = 0; i

void display_matrices(vector> matrix1, vector> matrix2) { cout

int main() { vector> D {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; vector> C = reverse(D); display_matrices(C, D); return 0; }

* For this problem, the console only reverses the numbers in each individual row rather than the whole sequence as the problem wants. Your assistance with this would also be so greatly appreciated. Thank you!

Console Window:

sh -c make -s ./main Matrix 1: 3 2 1 6 5 4 9 8 7 Matrix 2: 1 2 3 4 5 6 7 8 9

3. From the nested loops concept, Dynamic memory Allocation and Structures, we learned in the class, (10 points) a. Write a module to Transpose a Matrix A of size 4X3 (rows X columns) into Matrix B. Note, give appropriate values to the rows and columns of Matrix B. b. In the main function, DefineMatrix A and B. Display Matrix A and then invoke the newly written Transpose function to accomplish B=AT. Then display Matrix B in the following format. 4. Write another module Reverse, (5 points) a. To create a new Matrix C (3 X 3) from a Matrix D (3 X 3) where elements of Matrix C are modified as follows: An example of Matrix D : Resultant Matrix C must look like: b. Display the Matrices C and D in the format shown above

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!