Question: matrix_main.c: #include #include matrix.h void display_vector(float *v, int n); void display_matrix(float *m, int n); int main() { int n = 3, i; float m1[n][n]; float

matrix_main.c: #include #include "matrix.h" void display_vector(float *v, int n); void display_matrix(float *m,int n); int main() { int n = 3, i; float m1[n][n];matrix_main.c:

#include #include "matrix.h"

void display_vector(float *v, int n); void display_matrix(float *m, int n);

int main() { int n = 3, i; float m1[n][n]; float m2[n][n]; float m3[n][n];

// testing data float v[9] = { 1, 2, -1, -2, 0, 1, 1, -1, 0};

// assign value to m1 float *p = &v[0]; float *p1 = &m1[0][0]; for (i = 0; i

printf(" m1: "); display_matrix(&m1[0][0], n); printf("msum(m1):%.2f ", msum(&m1[0][0], n));

printf(" m2=m1': "); transpose_matrix(&m1[0][0], &m2[0][0], n); display_matrix(&m2[0][0], n); printf("msum(m2):%.2f ", msum(&m2[0][0], n));

multiply_matrix(&m1[0][0], &m2[0][0], &m3[0][0], n); printf(" m3=m1*m2': "); display_matrix(&m3[0][0], n); printf("msum(m3):%.2f ", msum(&m3[0][0], n));

float v1[] = {1, 1, 1}; printf(" v1: "); display_vector(v1, n); printf("vsum(v1):%.2f ", vsum(v1, n));

float v2[n]; multiply_vector(&m1[0][0], v1, v2, n); printf(" v2=m1*v1': "); display_vector(v2, n); printf("vsum(v2):%.2f", vsum(v2, n));

return 0; }

void display_vector(float *v, int n) { float *p = v; int i, j; for (i = 0; i

void display_matrix(float *m, int n) { float *p = m; int i, j; for (i = 0; i

matrix.h:

/* * your program signature */ #ifndef MATRIX_H #define MATRIX_H float vsum(float *v, int n); float msum(float *m, int n); void multiply_vector(float *m, float *v1, float *v2, int n); void transpose_matrix(float *m1, float *m2, int n); void multiply_matrix(float *m1, float *m2, float *m3, int n); #endif

matrix.c:

/* * your program signature */ #include #include "matrix.h" float vsum(float *v, int n) { // your implementation } float msum(float *m, int n) { // your implementation } void multiply_vector(float *m, float *vin, float *vout, int n) { // your implementation } void transpose_matrix(float *m1, float *m2, int n) { // your implementation } void multiply_matrix(float *m1, float *m2, float *m3, int n) { // your implementation }

Write C header program matrix. h to define the function prototypes of the following matrix operations, and C program matrix.c to implement the functions of the matrix operations. Use the provided the main function program matrix main.c to test the above functions. The output is like the following. Public test

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!