Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C programming Problem Statement You are asked to write three functions to perform basic matrix operations matrix addition, matrix multiplication, matrix transpose. You need to
C programming
Problem Statement You are asked to write three functions to perform basic matrix operations matrix addition, matrix multiplication, matrix transpose. You need to verify your functions by comparing the results with the examples in the laboratory procedure given in the last section. The running program in bash shell should look in Figure 1 (on the last page). An ideal program should: Get the array dimensions of operand matrices from the user (10pts) Let the user choose which operation will take place (10pts) Prompt an error message when dimensions of the arrays do not match column size and row size must match for matrix multiplication) (10pts) Demonstrate working functions All functions should be written based on prototypes be- low (70pts) Write a matrix addition function that has the following prototype. (20pts) // Function prototype for matrix addition Toid matida(int nRow . // Number of rows int ncol, // Number of columns double *. // Memory adress for the first operand matrix double ) // Memory adress for the second operand matris Write a matrix multiplication function that has the following prototype. (30pts) // Function prototype for matris multiplication Toid matMullint nRow1. // Number of rows - the first operand matrix int nCol1. // Number of columns - the first operand matris int ni ow2, // Number of TONS - the second oper and matrix int nco12, // Number of columns - the second oper and matrix double 1 [n Row1] [nCol1]. //The first oper and matrix double B[n Row 2 [nC012]) //The second operand matri Write a matrix transpose function that has the following prototype. (20pts) // Function prototype for matris multiplication Toid mattra(int now. // Number of rows int ncol, // Number of columns double 4 [nRow][nC01]) // The operand matrix Call addition, multiplication and transpose operations to solve the problems below. 1 2 3 11 [2 3 4 2 1 1 3 2 2 2 2 2 + 1 1 1 2 3] 3 2 1 2 3 25 = | (11 9 23 17 T [1 2 3] 2 3 4 3 2 1 1 2 3] 2 3 2 (3 4 1] Enter the number of rows for the first operand matrix: 2 Enter the number of columns for the first operand matrix: 3 Please choose the matrix operation you want to do: 2 Matrices addition Matrices multiplication Matrices transpose 3 1 Matrix addition operation selected Create the content of the first operand matrix: 1 2 3 321 Create the content of the second operand matrix: 1 11 111 Matrices Addition: 2.000000 3.000000 4.000000 4.000000 3.000000 2.000000 Please choose the matrix operation you want to do: Matrices addition Matrices multiplication Matrices transposeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started