Question: Write the API function TMatrix * newMatrix(unsigned int nrow, unsigned int ncol) that creates and returns a matrix of size rows x cols. rows :

 Write the API function TMatrix * newMatrix(unsigned int nrow, unsigned int

Write the API function TMatrix * newMatrix(unsigned int nrow, unsigned int ncol) that creates and returns a matrix of size rows x cols. rows : (non-negative value) giving the number of rows. cols : (non-negative value) giving the number of columns. If the allocation is not successful, the function should return NULL.

If the allocation is successful, the data field of the matrix should point to an array of pointers (representing the rows) and each pointer in that array should point to an array of TElement representing the values in that row.

The program mf-generate is provided to generate matrices-it helps you understand the format of the matrix data file. (provided below)

ncol) that creates and returns a matrix of size rows x cols.

rows : (non-negative value) giving the number of rows. cols : (non-negative

#define TElement int typedef struct Matrix { unsigned int nrow; unsigned int ncol; TElement **data; TMatrix; where nrow and ncol are numerical attributes representing the numbers of rows and columns of the matrix and data is a pointer to an array of row pointers. Each row pointer points to an array of elements of TElement type. TElement is defined as int

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!