Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

New concepts Multi-dimensional arrays Description This lab is intended to make you more familiar with 2-dimensional array. You are going to create a very simple

imageimageimageimage
New concepts Multi-dimensional arrays Description This lab is intended to make you more familiar with 2-dimensional array. You are going to create a very simple matrix class. a matrix (plural matrices) is a rectangular array or table of numbers, symbols, or expressions, arranged in rows and columns, which is used to represent a mathematical object or a property of such an object. (https://en.wikipedia.org/wiki/Matrix_(mathematics)). The numbers, symbols, or expressions in a matrix are called its entries or elements. Matrices are often used in mathematics, physics, and computer science(e.g. graph theory (gaming, route navigation, networking...), machine learning, image processing (next lab), encryption (later lab), and many more), and can be used to represent a wide range of mathematical objects, such as linear transformations, systems of linear equations, and more. They are typically denoted by a capital letter, such as A, B, or C, and the elements in the matrix are identified by their row and column indices, such as a_ij. Details of classes are as follows: Create project named Lab2_Fname_Lname. Matrix class Instance variables 1. array : double - Matrix data, can not be changed once created 2. rows : int - The number of rows in array, can not be changed once created 3. columns : int - The number of columns in array, can not be changed once created Constructors 1. Matrix (int, int) - creates zero matrix(https://en.wikipedia.org/wiki/Zero_matrix) of the given number of rows and columns 2. Matrix (double [ ] ) - create matrix from input 2D array Methods: (do not use getters and setters) add (Matrix) : Matrix - Elementwise addition of the given Matrix to this matrix and return a new Matrix sub (Matrix) : Matrix - Elementwise subtraction of the given Matrix from this matrix and return a new Matrix mult (Matrix) : Matrix - Elementwise multiplication (https://en.wikipedia.org/wiki/Hadamard_product_(matrices)) of the given Matrix with this matrix and return a new Matrix sum ( ) : double - The summation of all matrix elements subMatrix (int, int, int, int) :Matrix - Creates a subset of this Matrix, starting at the given row and column, with the given length and width. toString () : String - use the following: public String toString ()StringBuffer result = new StringBuffer () ; for (double row : array) result . append (Arrays. toString (row) ) ; result . append ( ' ') ; return result . toString () ; Lab2Test class Lab2Test has been provided to you. Download and add it to your project directory. Format your code with proper indentation and other formatting. Your code should be properly commented. Test plan and Javadoc are not required for this exercise, but in future labs they will be required. Output must match sample below exactly. Headers must be included on top of all classes to avoid loss of formatting marks. Class Header formatting will take this form: * A brief description of the role of this class Student Name: * Student Number: Course: CST8132 Object Oriented Programming * Program: CET-CS-Level 2 * Professor: James Mwangi PhD.Output Matrix B [3.3, 3.3, [3.3, 3.3, [3.3, 3.3, [3 3, 3.3, -. -. 31 I5: I5: I5: I: m m m -. 1, Matrix 1 [1.3, 2.3, 3.3] [4 3, 5.3, 5.3] [2.3, 3.3, 9.3] Matrix 2 [1 3, 2.3, 3.3] [2 3, 4.3, 5.3] [3 3, 5.3, 9.3] Matrix 1 + Matrix 2 [2.3, 4.3, 6.3] [3.3, 9.3, 12 3] [13.3, 14.3, 13.3] Matrix 2 + Matrix 1 [2.3, 4.3, 6.3] [3.3, 9.3, 12 3] [13.3, 14.3, 13.3] Matrix 1 - Matrix 2 [3 3, 3.3, 3.3] [2 3, 1.3, 3.3] [4 3, 2.3, 3.3] Matrix 2 Matrix 1 [3.3, 3.3, 3.3] [-2.3, -1.3, 3.3] [-4.3, 2.3, 3.3] Matrix 1 * Matrix 2 [1 3, 4.3, 9.3] [3.3, 23.3, 33.3] [21.3, 43.3, 31.3] 3.3] 3.3] 3.3] 3.3] Matrix 2 * Matrix 1 [1.0, 4.0, 9.0] [8.0, 20.0, 36.0] [21.0, 48.0, 81.0] sum of Matrix 1 = 45.00 sum of Matrix 2 = 36.00 subMatrix(1, 1, 1,1) of Matrix 1 [5.0] subMatrix(1, 1, 2,1) of Matrix 1 [5.0] [8.0] subMatrix(1, 1, 2,2) of Matrix 1 [5.0, 6.0] [8.0, 9.0]

New concepts Multi-dimensional arrays Description This lab is intended to make you more familiar with 2-dimensional array. You are going to create a very simple matrix class. a matrix (plural matrices) is a rectangular array or table of numbers, symbols, or expressions, arranged in rows and columns, which is used to represent a mathematical object or a property of such an object. (https://en. wikipedia.org/wiki/Matrix_(mathematics)). The numbers, symbols, or expressions in a matrix are called its entries or elements. Matrices are often used in mathematics, physics, and computer science(e.g. graph theory (gaming, route navigation, networking...), machine learning, image processing (next lab), encryption (later lab), and many more), and can be used to represent a wide range of mathematical objects, such as linear transformations, systems of linear equations, and more. They are typically denoted by a capital letter, such as A, B, or C, and the elements in the matrix are identified by their row and column indices, such as a_ij. Details of classes are as follows: Create project named Lab2_Fname_Lname. Matrix class Instance variables 1. array:double [][] - Matrix data, can not be changed once created 2. rows :int - The number of rows in array, can not be changed once created 3. columns : int - The number of columns in array, can not be changed once created Constructors 1. Matrix (int, int) - creates zero matrix(https://en.wikipedia.org/wiki/Zero_matrix) of the given number of rows and columns 2. Matrix (double[] []) - create matrix from input 2D array Methods: (do not use getters and setters) add (Matrix) : Matrix - Elementwise addition of the given Matrix to this matrix and return a new Matrix sub (Matrix) : Matrix - Elementwise subtraction of the given Matrix from this matrix and return a new Matrix mult (Matrix) : Matrix - Elementwise multiplication (https://en.wikipedia.org/wiki/Hadamard_product_(matrices)) of the given Matrix with this matrix and return a new Matrix sum(): double - The summation of all matrix elements subMatrix (int, int, int,int) : Matrix - Creates a subset of this Matrix, starting at the given row and column, with the given length and width. .toString(): String - use the following: public String toString ()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

include iostream class Matrix private double array int rows int columns public Matrixint r int c row... 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_2

Step: 3

blur-text-image_3

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

Smith and Roberson Business Law

Authors: Richard A. Mann, Barry S. Roberts

15th Edition

1285141903, 1285141903, 9781285141909, 978-0538473637

More Books

Students also viewed these Programming questions

Question

What general trade-off is involved in waiting-line decisions?

Answered: 1 week ago