Question: In Java Plz Write a class Matrix in Matrix.java that represents a Matrix. The type of each entry is a double. - public Matrix(int rows,
In Java Plz
Write a class Matrix in Matrix.java that represents a Matrix. The type of each entry is a double. - public Matrix(int rows, int columns) - Initialize a matrix of dimension rows x columns with all entries as zero. - public Matrix(double data[][]) - Initializes a matrix with a provided two dimensional array of data. - Here's a code snippet to initialize a 23 array for testing purposes: double test_2d_array [][]={{1,2,3},{4,5,6}}; - public double get(int row, int col) - Retrieve the entry at the given row and column - public void set(int row, int col, double value) - Set the entry at the given row and column to the given value - public Matrix add(Matrix other) -- Return a new matrix that is the result of adding this matrix with the other one - public Matrix sub(Matrix other) - Return a new matrix that is the result of this matrix subtracting the other one - public Matrix scalarmul(double scalar) - Return a new matrix that is the result of the scalar multiplication of this matrix with the given scalar - public Matrix transpose() - Return a new matrix that is the result of transposing
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
