- A
*constructor*that takes a two-dimensional array of type`double`and saves it (as an instance variable) as the values of the matrix.To be safe, your instance variable should be a

*copy*of the parameter, so that the contents of your Matrix's array cannot be changed beyond your control.To copy the two-dimensional array, you must instantiate a new two-dimensional array and copy the original array's contents into your new array.

- An
`arraysAreEqual(double[][] one, double[][] two)`method that compares the two arrays to see if they are the same. The two arrays are the same if:- They agree in the size of both of their dimensions.
- The contents of the two arrays are the same.

The

`.equals(Object)`method included with this lab calls your`arraysAreEqual`method, so that`Matrix`equality of two matrices depends on the contents of those matrices.Until this method is working, the rest of the JUnit tests will not work properly.

- A
`toString`method that neatly shows the contents of the matrix. In your string use "\n" to insert a line break, and use "\t" where you want a tab between elements. Include JUnit tests that print these strings to the console (using System.out.println) for visual inspection, in addition to any automated tests you perform. Your toString method will come in handy for debugging the other methods. - A
`scaleRow`method that takes a row number (an integer) and a scale factor (a double), and multiplies that row by the given scale factor. This method does not return anything. It just modifies the matrix.In this lab, rows are numbered as arrays are indexed. Thus, the top row in the matrix is row 0, and the bottom row is numbered one less than the number of rows in the matrix.

- An
`addRows`method that takes two row numbers as parameters, and adds the two rows together, storing the result in place of the second of the two rows. - A
`plus`method that takes another Matrix as its parameter and returns the matrix that results from adding this matrix by the given one. Matrix addition is only valid when the two matrices are the same size in both dimensions, so your`plus`method should throw an IllegalArgumentException when this is not the case. - A
`transpose`method that takes no parameters and returns a new matrix that is the transpose of this one. Recall that the columns of the transposed matrix have the same values as the rows of the original matrix. - A
`times`method that takes another Matrix as its parameter and returns the matrix that results from multiplying this matrix by the given one. Recall that when you multiply two matrices A and B, the value in the cell at row*r*and column*c*of the resulting matrix is the dot product of A's row*r*with B's column*c*. Also recall that matrix multiplication is only valid when the number of columns of the first matrix is equal to the number of rows of the second, so your`times`method should throw an IllegalArgumentException when this is not the case.

- Complete the
`cover-page.txt`file in the repository for this lab. Just open it up in your eclipse editor and type in your responses. - In the
`cover-page.txt`file, be sure to indicate anybody with whom you have collaborated on the work you are submitting. - You must commit all of your work to your repository. It's best to do this from the top-most level of your repository, which bears your name and student ID.
- You must demo the commited work to a TA. Make sure the TA knows that your demo is for credit at this point.
- The TA must have your name and information recorded on a lab demo sheet for this lab to be graded and counted. Be sure your name and ID are written clearly on the TA's demo sheet.

Last modified 22:14:03 CST 11 November 2009 by Ron K. Cytron