Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Matrix Utilities. A matrix is a two dimensional array. It can also be descried as a pointer to a pointer or an array of pointers.

Matrix Utilities.

A matrix is a two dimensional array. It can also be descried as a pointer to a pointer or an array of pointers. In this program we will write several small utilitiy functions to test mastery of this concept. The function signatures and descriptions follow below. Also, you will want to include the stdbool.h header file for this exercise that contains the definition of a an enumerated type named bool. It should only two values: true and false. You may make the assumption that the matrix will be a square matrix meaning that the number of rows equals the number of columns in the matrix.

MUST Implement ALL of these functions AS IS:

int** makeMatrix(int n);

void printMatrix(int **A, int n);

bool sumEqual(int **A, int **B, int n);

bool isEqual(int **A, int **B, int n);

int diagonal(int **A, int n);

int** sumMatrix(int **A, int **B, int n);

int** product(int **A, int **B, int n);

Please read the description of these functions carefully.

The makeMatrix function should dynamically allocate memory for a matrix of size n and allow the user to enter values for each position of the matrix from left to right row by row then return the created matrix to the main function.

The printMatrix function should print out a matrix row by row legibly enough so that a grader can see which number corresponds to each position of the matrix.

In the sumEqual function you will sum up all the elements in each matrix and see if the sum of each array is equal to one another. The function returns true if the sums are equal or returns false if the sums do not equal one another. Function takes two matrices and a size integer.

image text in transcribed

In the isEqual function you will check each matrix element by element and see if each element matrix A is equal to its corresponding element in Matrix B. Return true if this is the case and false if even one element is not equal to its corresponding element in the other matrix. Function takes two matrices and a size integer.

image text in transcribed

In the diagonal function you will calculate the product of the elements along the diagonal of the matrix and return that number. Function takes a single matrix and an integer size of that matrix and returns the product.

image text in transcribed

n the sumMatrix function you will find the summation of the two matrices. Matrix summation is done element by element in the two matrices. Function takes two matrices and a size integer and returns a new matrix that is the element by element summation.

image text in transcribed

In the product function you will find the matrix product of multiplying two matrices together. Function takes two matrices and a size integer and returns a new matrix that is the result of matrix multiplication. Matrix multiplication is done as follows:

image text in transcribed

Your main function should prompt the user to input the size of the two matrices, and then create the two matrices by calling appropriate functions. Then it should call the following functions on the two matrices: sumEqual, isEqual, diagonal, sumMatrix, and product.

Few other things.....:

First, create two matrices on stack. Then another empty matrix on stack. Then compute the matrix product. You have to compute the product on HEAP.

**** OUTPUT ****

image text in transcribed

Language in C.

Example (sumEqual): and is true. 1 2 3 4 5 5 0 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions