Package hlcd.testing.optimizationTester
Class MatrixCellAccessorTester
java.lang.Object
hlcd.testing.optimizationTester.MatrixCellAccessorTester
Tests the logic of getting and setting cells in the matrix. A matrix is
generated randomly, another matrix will start as a null matrix. The test
is to copy from the generated matrix into the null matrix. The objective
is to have both matrices become equal. This uses the notion of getting a
cell and setting another.
- Since:
- 1.8
- Version:
- 1.0 (February 18th, 2022)
- Author:
- Maysara Al Jumaily
-
Constructor Summary
ConstructorsConstructorDescriptionChooses a random matrix dimension.MatrixCellAccessorTester(byte n, byte k)Creates the matrix based on thenandkvalues specified. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif the two specified matrices are equal,falseotherwise.booleanReturnstrueif the test was successful in the sense that both implementations yielded the same results,falseotherwise.voidtestCellAccessors(long iterations)Will create x random quaternary matrices, where x is the number of iterations specified and copy each matrix cells into a new matrix by usinggetCellandsetCell.voidtestCellAccessors(Matrix matrix)Will copy the cells of the specified matrix into a new matrix by usinggetCellandsetCell.
-
Constructor Details
-
MatrixCellAccessorTester
public MatrixCellAccessorTester()Chooses a random matrix dimension. -
MatrixCellAccessorTester
public MatrixCellAccessorTester(byte n, byte k)Creates the matrix based on thenandkvalues specified.- Parameters:
n- the number of columns in the matrixk- the number of rows in the matrix
-
-
Method Details
-
testCellAccessors
public void testCellAccessors(long iterations)Will create x random quaternary matrices, where x is the number of iterations specified and copy each matrix cells into a new matrix by usinggetCellandsetCell. An error message will be printed if the two matrices don't match. This is benchmarked but the amount of time doesn't have any significance.- Parameters:
iterations- the number of random matrices to be tested
-
testCellAccessors
Will copy the cells of the specified matrix into a new matrix by usinggetCellandsetCell. A check will then occur to ensure both matrices contain the same vectors. An error message will be printed if the two matrices don't match.- Parameters:
matrix- the matrix to copy the elements from
-
areEqual
Returnstrueif the two specified matrices are equal,falseotherwise.- Parameters:
m1- the first matrix used for checkingm2- the second matrix used for checking- Returns:
trueif the two specified matrices are equal,falseotherwise
-
isValidImplementation
public boolean isValidImplementation()Returnstrueif the test was successful in the sense that both implementations yielded the same results,falseotherwise.- Returns:
trueif the test was successful in the sense that both implementations yielded the same results,falseotherwise
-