Class SparseSquareMatrix

  • All Implemented Interfaces:

    public class SparseSquareMatrix
    extends Object
    implements Serializable
    A sparse, square matrix, implementing using two arrays of sparse vectors, one representation for the rows and one for the columns. For matrix-matrix product, we might also want to store the column representation. Derived from For additional documentation, see Section 4.4 of Introduction to Programming in Java: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.
    See Also:
    Serialized Form
    • Constructor Detail

      • SparseSquareMatrix

        public SparseSquareMatrix​(int N)
        initialize an N-by-N matrix of all 0s
        N - - size
    • Method Detail

      • put

        public void put​(int i,
                        int j,
                        double value)
        set A[i][j] = value
        i -
        j -
        value -
      • get

        public double get​(int i,
                          int j)
        access a value at i,j
        i -
        j -
        return A[i][j]
      • nnz

        public int nnz()
        return the number of nonzero entries (not the most efficient implementation)