Class SparseFieldMatrix<T extends FieldElement<T>>

  • Type Parameters:
    T - the type of the field elements
    All Implemented Interfaces:
    AnyMatrix, FieldMatrix<T>

    public class SparseFieldMatrix<T extends FieldElement<T>>
    extends AbstractFieldMatrix<T>
    Sparse matrix implementation based on an open addressed map.
    Since:
    2.0
    • Constructor Detail

      • SparseFieldMatrix

        public SparseFieldMatrix​(Field<T> field)
        Creates a matrix with no data.
        Parameters:
        field - field to which the elements belong
      • SparseFieldMatrix

        public SparseFieldMatrix​(Field<T> field,
                                 int rowDimension,
                                 int columnDimension)
                          throws java.lang.IllegalArgumentException
        Create a new SparseFieldMatrix with the supplied row and column dimensions.
        Parameters:
        field - field to which the elements belong
        rowDimension - the number of rows in the new matrix
        columnDimension - the number of columns in the new matrix
        Throws:
        java.lang.IllegalArgumentException - if row or column dimension is not positive
      • SparseFieldMatrix

        public SparseFieldMatrix​(SparseFieldMatrix<T> other)
        Copy constructor.
        Parameters:
        other - The instance to copy
      • SparseFieldMatrix

        public SparseFieldMatrix​(FieldMatrix<T> other)
        Generic copy constructor.
        Parameters:
        other - The instance to copy
    • Method Detail

      • addToEntry

        public void addToEntry​(int row,
                               int column,
                               T increment)
                        throws MatrixIndexException
        Change an entry in the specified row and column.

        Row and column indices start at 0 and must satisfy

        • 0 <= row < rowDimension
        • 0 <= column < columnDimension
        otherwise a MatrixIndexException is thrown.

        Specified by:
        addToEntry in interface FieldMatrix<T extends FieldElement<T>>
        Specified by:
        addToEntry in class AbstractFieldMatrix<T extends FieldElement<T>>
        Parameters:
        row - row location of entry to be set
        column - column location of entry to be set
        increment - value to add to the current matrix entry in row,column
        Throws:
        MatrixIndexException - if the row or column index is not valid
      • createMatrix

        public FieldMatrix<T> createMatrix​(int rowDimension,
                                           int columnDimension)
                                    throws java.lang.IllegalArgumentException
        Create a new FieldMatrix of the same type as the instance with the supplied row and column dimensions.
        Specified by:
        createMatrix in interface FieldMatrix<T extends FieldElement<T>>
        Specified by:
        createMatrix in class AbstractFieldMatrix<T extends FieldElement<T>>
        Parameters:
        rowDimension - the number of rows in the new matrix
        columnDimension - the number of columns in the new matrix
        Returns:
        a new matrix of the same type as the instance
        Throws:
        java.lang.IllegalArgumentException - if row or column dimension is not positive
      • getEntry

        public T getEntry​(int row,
                          int column)
                   throws MatrixIndexException
        Returns the entry in the specified row and column.

        Row and column indices start at 0 and must satisfy

        • 0 <= row < rowDimension
        • 0 <= column < columnDimension
        otherwise a MatrixIndexException is thrown.

        Specified by:
        getEntry in interface FieldMatrix<T extends FieldElement<T>>
        Specified by:
        getEntry in class AbstractFieldMatrix<T extends FieldElement<T>>
        Parameters:
        row - row location of entry to be fetched
        column - column location of entry to be fetched
        Returns:
        matrix entry in row,column
        Throws:
        MatrixIndexException - if the row or column index is not valid
      • multiplyEntry

        public void multiplyEntry​(int row,
                                  int column,
                                  T factor)
                           throws MatrixIndexException
        Change an entry in the specified row and column.

        Row and column indices start at 0 and must satisfy

        • 0 <= row < rowDimension
        • 0 <= column < columnDimension
        otherwise a MatrixIndexException is thrown.

        Specified by:
        multiplyEntry in interface FieldMatrix<T extends FieldElement<T>>
        Specified by:
        multiplyEntry in class AbstractFieldMatrix<T extends FieldElement<T>>
        Parameters:
        row - row location of entry to be set
        column - column location of entry to be set
        factor - multiplication factor for the current matrix entry in row,column
        Throws:
        MatrixIndexException - if the row or column index is not valid
      • setEntry

        public void setEntry​(int row,
                             int column,
                             T value)
                      throws MatrixIndexException
        Set the entry in the specified row and column.

        Row and column indices start at 0 and must satisfy

        • 0 <= row < rowDimension
        • 0 <= column < columnDimension
        otherwise a MatrixIndexException is thrown.

        Specified by:
        setEntry in interface FieldMatrix<T extends FieldElement<T>>
        Specified by:
        setEntry in class AbstractFieldMatrix<T extends FieldElement<T>>
        Parameters:
        row - row location of entry to be set
        column - column location of entry to be set
        value - matrix entry to be set in row,column
        Throws:
        MatrixIndexException - if the row or column index is not valid