Question: Part 1: 1.Write method rows, cols, get, set, and scalar multiplication method, mul outlined above. a. discussing using class methods versus direct instance variable referencing.

Part 1:

1.Write method rows, cols, get, set, and scalar multiplication method, mul outlined above. a. discussing using class methods versus direct instance variable referencing.

2. Add code to the driver program to test the following operations. a. In the section labeled Part II, write a code segment that will create a Matrix named T which contains 3 times the Matrix B using the mul method. b. Write a code segment that prints the contents of Matrix T without using the toString method; i.e. use only the new methods we wrote in this part. c. Using the get and set methods, change the element in the lower right corner of Matrix T to the value -2.5. Then display the contents of Matrix T using the toString method. In referring to the element in the lower right corner of the array T pretend you dont know the dimensions of the matrix and ask matrix T for its dimensions.

Part 2:

1. Write the static method id that returns the n x n identity matrix, (I from your math class). This method is decribed in the table on the previous page. 2. Write the add and sub methods. BUT have the add method perform the addition using row-major traversal and sub perform its operations using a column-major traversal of the matrices. (For these methods the order of traversal does not effect the final answer (for other operations, I often does) but I want to know that you understand what these two traversals are and how to code them.)

Part 3:

  1. Write the trace, equals, and isSymmetric methods.

Part 4:

1. Write the transpose, and matrix mul methods 2. Write an alternative isSymmetric method named isSymmetric2 which uses the equals and transpose methods. This will be a very brief method!

Output :

Part 1:

9.00 -6.00

6.00 12.00

3.00 -9.00

| 9.00 -6.00 |

| 6.00 12.00 |

| 3.00 -2.50 |

Part 2: Addition of Matrix A and B is undefined! 

| 5.00 2.00 3.00 |

|4.00 9.00 6.00|

|7.00 8.00 13.00|

Part 3: Trace of SQ is 15.00 

Part 4: Matrix SQ is NOT symmetric.

Matrix SY is symmetric. | -1.00 -1.00 | | 20.00 -22.00 |

| -14.00 1.00 -3.00 |

| 12.00 6.00 30.00 | | -14.00 -2.00 -15.00 |

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!