Package org.ejml.data

Class BMatrixRMaj

java.lang.Object
org.ejml.data.BMatrixRMaj
All Implemented Interfaces:
Serializable, Matrix, ReshapeMatrix

public class BMatrixRMaj extends Object implements ReshapeMatrix
Dense matrix composed of boolean values
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean[]
    1D row-major array for storing theboolean matrix
    int
    Number of columns in the matrix.
    int
    Number of rows in the matrix.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BMatrixRMaj(int numRows, int numCols)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends Matrix>
    T
    Creates an exact copy of the matrix
    create(int numRows, int numCols)
    Creates a new matrix of the same type with the specified shape
    Creates a new matrix with the same shape as this matrix
    void
    fill(boolean value)
    Sets every element in the matrix to the specified value
    boolean
    get(int index)
     
    boolean
    get(int row, int col)
     
    int
    getIndex(int row, int col)
     
    int
    Returns the number of columns in this matrix.
    int
     
    int
    Returns the number of rows in this matrix.
    Returns the type of matrix
    boolean
    isInBounds(int row, int col)
    Determines if the specified element is inside the bounds of the Matrix.
    void
    Prints the matrix to standard out using standard formatting.
    void
    print(String format)
    Prints the matrix to standard out with the specified formatting.
    void
    reshape(int numRows, int numCols)
    Equivalent to invoking reshape(numRows,numCols,false);
    void
    set(int row, int col, boolean value)
     
    void
    setTo(Matrix original)
    Sets this matrix to be identical to the 'original' matrix passed in.
    int
    sum()
    Returns the total number of elements which are true.
    boolean
    unsafe_get(int row, int col)
     
    void
    unsafe_set(int row, int col, boolean value)
     
    void
    Sets all values inside the matrix to zero

    Methods inherited from class java.lang.Object

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

    • data

      public boolean[] data
      1D row-major array for storing theboolean matrix
    • numRows

      public int numRows
      Number of rows in the matrix.
    • numCols

      public int numCols
      Number of columns in the matrix.
  • Constructor Details

    • BMatrixRMaj

      public BMatrixRMaj(int numRows, int numCols)
  • Method Details

    • getNumElements

      public int getNumElements()
    • getIndex

      public int getIndex(int row, int col)
    • fill

      public void fill(boolean value)
      Sets every element in the matrix to the specified value
      Parameters:
      value - new value of every element
    • get

      public boolean get(int index)
    • get

      public boolean get(int row, int col)
    • set

      public void set(int row, int col, boolean value)
    • unsafe_get

      public boolean unsafe_get(int row, int col)
    • unsafe_set

      public void unsafe_set(int row, int col, boolean value)
    • isInBounds

      public boolean isInBounds(int row, int col)
      Determines if the specified element is inside the bounds of the Matrix.
      Parameters:
      row - The element's row.
      col - The element's column.
      Returns:
      True if it is inside the matrices bound, false otherwise.
    • sum

      public int sum()
      Returns the total number of elements which are true.
      Returns:
      number of elements which are set to true
    • reshape

      public void reshape(int numRows, int numCols)
      Description copied from interface: ReshapeMatrix
      Equivalent to invoking reshape(numRows,numCols,false);
      Specified by:
      reshape in interface ReshapeMatrix
      Parameters:
      numRows - The new number of rows in the matrix.
      numCols - The new number of columns in the matrix.
    • getNumRows

      public int getNumRows()
      Description copied from interface: Matrix
      Returns the number of rows in this matrix.
      Specified by:
      getNumRows in interface Matrix
      Returns:
      Number of rows.
    • getNumCols

      public int getNumCols()
      Description copied from interface: Matrix
      Returns the number of columns in this matrix.
      Specified by:
      getNumCols in interface Matrix
      Returns:
      Number of columns.
    • zero

      public void zero()
      Description copied from interface: Matrix
      Sets all values inside the matrix to zero
      Specified by:
      zero in interface Matrix
    • copy

      public <T extends Matrix> T copy()
      Description copied from interface: Matrix
      Creates an exact copy of the matrix
      Specified by:
      copy in interface Matrix
    • setTo

      public void setTo(Matrix original)
      Description copied from interface: Matrix
      Sets this matrix to be identical to the 'original' matrix passed in.
      Specified by:
      setTo in interface Matrix
    • print

      public void print()
      Description copied from interface: Matrix
      Prints the matrix to standard out using standard formatting. This is the same as calling print("%e")
      Specified by:
      print in interface Matrix
    • print

      public void print(String format)
      Description copied from interface: Matrix
      Prints the matrix to standard out with the specified formatting.
      Specified by:
      print in interface Matrix
      Parameters:
      format - printf style formatting for a float. E.g. "%f"
      See Also:
    • createLike

      public BMatrixRMaj createLike()
      Description copied from interface: Matrix
      Creates a new matrix with the same shape as this matrix
      Specified by:
      createLike in interface Matrix
    • create

      public BMatrixRMaj create(int numRows, int numCols)
      Description copied from interface: Matrix
      Creates a new matrix of the same type with the specified shape
      Specified by:
      create in interface Matrix
    • getType

      public MatrixType getType()
      Description copied from interface: Matrix
      Returns the type of matrix
      Specified by:
      getType in interface Matrix