Interface MatrixInterface

All Known Implementing Classes:
Matrix3, Point, Vector3

public interface MatrixInterface
Defines the core contract for a matrix implementation. This interface provides methods for accessing dimensions, getting and setting individual elements, retrieving the underlying data array, and creating a copy of the matrix. It also includes a default method for generating a formatted string representation.

A huge thank you to Mindbourne for their AP Maths videos on matrices.

Author:
Lehlogonolo Poole
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the number of columns in the matrix.
    Creates and returns a deep copy of this matrix.
    double[][]
    get()
    Returns the underlying 2D array that represents the matrix data.
    double
    get(int row, int col)
    Retrieves the value of a specific element in the matrix.
    int
    Returns the number of rows in the matrix.
    default String
    Generates a formatted string representation of the matrix, suitable for console output.
  • Method Details

    • rows

      int rows()
      Returns the number of rows in the matrix.
      Returns:
      The number of rows.
    • cols

      int cols()
      Returns the number of columns in the matrix.
      Returns:
      The number of columns.
    • get

      double get(int row, int col)
      Retrieves the value of a specific element in the matrix.
      Parameters:
      row - The row index of the element (0-based).
      col - The column index of the element (0-based).
      Returns:
      The value at the specified position.
    • get

      double[][] get()
      Returns the underlying 2D array that represents the matrix data.
      Returns:
      A 2D double array containing the matrix values.
    • copy

      Creates and returns a deep copy of this matrix.
      Returns:
      A new MatrixInterface instance with the same values as the original.
    • toMatrixString

      default String toMatrixString()
      Generates a formatted string representation of the matrix, suitable for console output. The matrix is enclosed in box-drawing characters, and columns are aligned for readability. Values are formatted to four decimal places.
      Returns:
      A string representing the formatted matrix.