Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The main focus of this question is for you to practice using multi-dimensional arrays in C. Algorithmically the problem is fairly straightforward. You should be
The main focus of this question is for you to practice using multi-dimensional arrays in C. Algorithmically the problem is fairly straightforward. You should be familiar with the process of multiplying two matrices from an introductory linear algebra course. Given an l x m matrix A and an m x n matrix B a1.1 a1.2ai a21 a22 a2m rm 1,1 1,2 2,1 2,2"" dei at2 a In m,n our task is to compute an x n matrix (C C1,1 C1,2 C2,1 C2.2 c 2,n Ce, .. c where In cij- abx.j, for all 1 Sis and 1 sjSn. i,kVk.j Your program should read the matrices Aand B from stdin and write the matrix C to stdout. Implement your program in a file matrixmult.c and add it to SVN. The following are the requirements on the format of the input your program must be able to consume and of the output your program must produce Input format: The input of your program consists of a file split into three parts. The first and second part are separated by an empty line, as are the second and third part of the input The first part consists of a single line containing the three integers !, m, and n, separated by spaces. The second part represents the matrix A. This part has lines. Each line has m floating point numbers on it. The jth number on the ith line is the value aij. The third part represents the matrix B. This part has m lines. Each line has n floating point numbers on it. The jth number on the ith line is the value bij. Each floating point number in Parts 2 and 3 are represented with two digits after the decimal point. Here's an example input: 3 2 4 3.00 4.50 1.25 -1.00 2.00 -3.00 1.00 1.00 -2.00 4.00 5.25 3.25 -2.25 1.00 This represents the input matrices 3 4.5 A-1.25-1and B- 5.25 3.25 -2.25 1 Output format: The output of your program must consist of two parts, not separated by any blank lines. The first part consists of a single line with two integers on it, l and n. The second part consists of l lines. Each line has n floating point numbers on it. The jth number on the ith line is the value cij Each value must be represented with two digits after the decimal point. The output for the above sample input should look like this: 3 4 26.63 17.63 -16.12 16.50 -4.00-2.00-0.25 4.00 13.75-7.75 2.75 5.00 This represents the output matrix 26.625 17.625-16.125 16.5 2 13.75 -7.752.75 0.25 4 5 (Due to the requirement that each number should be represented with two digits of precision after the decimal point, the first three numbers on the first line are rounded. You do not have to worry about implementing a particular rounding rule. Simply produce the output that printf's %.2f format specifier produces.)
Step 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