Class AbstractMatrix

  • All Implemented Interfaces:
    Matrix
    Direct Known Subclasses:
    DenseMatrix, SparseMatrix

    public abstract class AbstractMatrix
    extends Object
    implements Matrix
    Abstract class for matrix that provides an implementation for common methods.
    Author:
    Geoffroy Jamgotchian
    • Constructor Detail

      • AbstractMatrix

        public AbstractMatrix()
    • Method Detail

      • getEstimatedNonZeroValueCount

        protected abstract int getEstimatedNonZeroValueCount()
        Get an estimation of non zero value count.
        Returns:
        an estimation of non zero value count
      • checkBounds

        protected void checkBounds​(int i,
                                   int j)
        Check that row i and column j are in matrix bounds.
        Parameters:
        i - row index
        j - column index
      • copy

        public Matrix copy​(MatrixFactory factory)
        Copy this matrix using another implementation. This method is not allowed to return this.
        Specified by:
        copy in interface Matrix
        Parameters:
        factory - a matrix factory to create the copy.
        Returns:
        a copy of the matrix
      • add

        public Matrix add​(Matrix other)
        Description copied from interface: Matrix
        Addition the matrix with another one (this + other). The resulting matrix has the same implementation as this matrix.
        Specified by:
        add in interface Matrix
        Parameters:
        other - the other matrix
        Returns:
        the result of the addition of this matrix and the other one
      • times

        public Matrix times​(Matrix other)
        Description copied from interface: Matrix
        Multiply the matrix by another one. The resulting matrix has the same implementation as this matrix.
        Specified by:
        times in interface Matrix
        Parameters:
        other - the other matrix
        Returns:
        the result of the multiplication of this matrix by the other one