Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

outline: M public static void main(String[] args) { 11 given matrices w double[]) a = { {-2, 1, 3}, {4, 1, 6} }; double b

image text in transcribed
outline:
image text in transcribed
image text in transcribed
image text in transcribed
M public static void main(String[] args) { 11 given matrices w double[]) a = { {-2, 1, 3}, {4, 1, 6} }; double b = { { 3, -2 }, { 2, 4). { 1, -3} }; double[11] sq { { 1, 2, 3 }, { 4, 5, 6}, {7, 8, 9) }; double sy = { { 1, 1, -1}, {1, 2, 0 }, {-1, 0, 5} }; 7 Part 1 System.out.println("Part 1:"); 17 Part II System.out.println(" Part II:"); // Part III System.out.println(" Part III:"); 1/ Part IV System.out.println(" Part IV:"); // Part 1 System.out.println(" Part V:): Part I: 1 -2.00 1.00 3.00 1 4.00 1.00 6.00 1 3.00 -2.00 12.00 4.00 1 1.00 -3.00 Part II: 9.00 -6.00 6.00 12.00 3.00 -9.00 19.00 -6.00 6.00 12.00 1 3.00 -2.50 | Part III: Addition of Matrix A and B is undefined! 1 5.00 2.00 3.00 | 1 4.00 9.00 6.00 1 1 7.00 8.00 13.00 Part IV: Trace of SQ is 15.00 Part V: Matrix SQ is NOT symmetric. Matrix Sy is symmetric. 1 -1.00 -1.00 1 120.00-22.00 1-14.00 1.00 -3.00 12.00 6.00 30.00 | -14.00 -2.00 -15.00 part 1 (Basic Class Outline) 1. Begin by creating the Matrix class. A Matrix will be represented as a 2D array of doubles. Add a single instance variable m for referring to a 2-dimensional array of doubles 2. Create the three class constructors for the class. Each constructor should initialize the instance variable m appropriately 3. We will write the class method toString together 4. Add code to the driver program to test the following operations. In the MatrixDriver class, there are several 2D arrays named with lower case letters, a, b, sq, and sy. In the section labelled Part I, write code to create four Matrices named A, B, 50, and SY using a. b. sq, and sy to initialize them. b. print matrices A and B using the toString method. a. Part II 1. Write method rows.cols, get, set, and scalar multiplication method, mul outlined above. discussing using class methods versus direct instance variable referencing 2. Add code to the driver program to test the following operations. 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 Write a code segment that prints the contents of Matrix T without using the tostring method; 1.0, use only the new methods we wrote in this part Using the get and set methods, change the element in the lower right comer 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 comer of the stray T.pretend you don't know the dimensions of the matrix and ask matrix T for its dimensions Part III Write the statio method id that returns then * 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.) 3. Add code to the driver program to test the following operations Declare a variable and attempt to perform the operation C - + B. If the operation is successful print the contents of Matrix c. If the method is not successful, print the message "Addition of Matricos A and B is undefined b. Declare a variable and attempt to perform the operation 1 - 30 - 3-1 where I is the 3 * 3 identity matrix. If the operation is successful print the contents of Matrix D. If the method is not successful, print the message "Addition of Matrices 50 and 31 18 undefined 1 a. Part IV 1. Write the trace, equals, and is Symmetric methods. 2. Add code to the driver program to test the following operations Print the trace of matrix so b. Write a code segment to check whether A = 3.A and print either the message "A and 3A are equal" or "A and 3A are not equal" Write a code segment to see if Matrix A is symmetric and print either the message "A is symmetric" or "A is not symmetric d. Write a code segment to see if Matrix SQ is symmetric and print either the message "SQ is symmetric" or "So is not symmetric c. Part V 1. 2 Write the transpose, and matrix mul methods Write an alternative susymmetric method named Symeetric which uses the equals and transpose methods. This will be a very brief method! 3. Add code to the driver program to demonstrate the following operations: Write a code segment to determine il matrix 50 is symmetric using the insynmetric method. Print a message indicating whether it is SO 18 Symmetrio" or "So is Not symmetric b. Write a code segment to determine if matrix sy is symmetric using the 1 asymmetric method. Print a message indicating whether it is Sy is Symmetrio" or "SY is Not symetric c. Write a code segment to attempt the multiplication C = AB If the multiplication is successful, print the product matrix not display the message "AB is not defined d. Write a code segment to attempt the multiplication C = BA. If the multiplication is successful, print the product matrix C. not display the message "BA is not defined

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions