当前位置 |首页 > 作业代写 > JAVA代写 >
分享这个代写网站给同学或者朋友吧!

CSC 1011                           Programming Assignment #5              Fall 2017

Problem Statement:

Your assignment to design and Implement an Algorithm is Java to perform the following.  . Addition and Multiplication of the arrays..  Below is the statement multiplying 2 matrices, As for Matrix Addition, you can come up with the algorithm.

Multiplication of two matrices is little complicated as compared to the addition of the two matrices. One of the basic condition for the multiplication of two matrices is number of columns of the first matrix equal to the number of rows of second matrix. This is the main condition for the multiplication of two matrices.1. Input: We enter the number of rows, columns of two matrices. Later we enter the elements of the two matrices.2. Explanation: while multiplying two matrices, we need to multiply the rows, columns. To get the element of the first row, first column element of the resultant matrix……we need to multiply the corresponding first row elements of first matrix with first column elements of second matrix and then add them. In the same way if we need to get the nth row,  ith column…..then we need to multiply the corresponding nth row elements of the first matrix with ith column of the second matrix and then add them.From the above picture we can explain that we got the first row, first column element as 1*5+7*2=19….In the same way first row, second column element as 1*6+2*8=22.In the same way we can get the value of the element we need.

3.Output: We need to display the resultant matrix of multiplication.From the above explanation we shall write the code for multiplication.

So, Let’s say we have two matrices – Matrix A with m rows and n columns and Matrix B with n rows and p columns. Let’s say we have to multiple a 2×3 matrix with a 3×2 matrix. Here is how we need to perform multiplication.

· The element in the first row first column of matrix A should be multiplied with the element in the first row first column of matrix B. The element in the first row second column of matrix A should be multiplied with the element in the second row first column of matrix B. Similarly the element in the first row third column of matrix A should be multiplied with the element in the third row first column of matrix B. The result of all these multiplication should be added together to get the first element of the resultant matrix.

· Similar step has to be followed by taking the elements in first row of matrix A and elements of second column in matrix B.

· Continue the above steps for second row of matrix A with first column of matrix B and second row of matrix A with second column of matrix B.

· The resultant matrix will be a 2*2 matrix.

Here is a pictorial representation of multiplying a 2*3 matrix with 3*2 matrix

Here are some of the points to be noted about matrix multiplication, as stated above.

1. In order to multiply two matrices, the number of columns in the first matrix should be equal to the number of rows in the second matrix. Otherwise matrix multiplication cannot be done.

2. The resultant of multiplication of m*n matrix with n*p matrix will be a m*p matrix.

3. Matrix multiplication is not cumulative. It means, Matrix A x B Matrix B x A.

This project is listed on Page 224, Chapter 6 , Arrays , of the textbook.

代写