Class MatrixCellAccessorTester

java.lang.Object
hlcd.testing.optimizationTester.MatrixCellAccessorTester

public class MatrixCellAccessorTester extends Object
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

    Constructors
    Constructor
    Description
    Chooses a random matrix dimension.
    MatrixCellAccessorTester​(byte n, byte k)
    Creates the matrix based on the n and k values specified.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    areEqual​(Matrix m1, Matrix m2)
    Returns true if the two specified matrices are equal, false otherwise.
    boolean
    Returns true if the test was successful in the sense that both implementations yielded the same results, false otherwise.
    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 using getCell and setCell.
    void
    Will copy the cells of the specified matrix into a new matrix by using getCell and setCell.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MatrixCellAccessorTester

      public MatrixCellAccessorTester()
      Chooses a random matrix dimension.
    • MatrixCellAccessorTester

      public MatrixCellAccessorTester(byte n, byte k)
      Creates the matrix based on the n and k values specified.
      Parameters:
      n - the number of columns in the matrix
      k - 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 using getCell and setCell. 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

      public void testCellAccessors(Matrix matrix)
      Will copy the cells of the specified matrix into a new matrix by using getCell and setCell. 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

      public boolean areEqual(Matrix m1, Matrix m2)
      Returns true if the two specified matrices are equal, false otherwise.
      Parameters:
      m1 - the first matrix used for checking
      m2 - the second matrix used for checking
      Returns:
      true if the two specified matrices are equal, false otherwise
    • isValidImplementation

      public boolean isValidImplementation()
      Returns true if the test was successful in the sense that both implementations yielded the same results, false otherwise.
      Returns:
      true if the test was successful in the sense that both implementations yielded the same results, false otherwise