jvx.numeric

## Class PnSparseMatrix

- java.lang.Object
- - jv.object.PsObject
  - - jvx.numeric.PnSparseMatrix

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, PsUpdateIf, PdMatrixIf
  Direct Known Subclasses:
    PnStiffMatrix

      public class PnSparseMatrix
      extends PsObject
      implements PdMatrixIf

  Sparse matrix representation.

  Class was extracted from earlier code in jvx.numeric.PnStiffMatrix.

  See Also:
    Serialized Form
  Author:
    Konrad Polthier, Eike Preuss, Klaus Hildebrandt, Matthias Nieser, Konstantin Poelke
  Version:
    09.05.17, 5.80 revised (poe) Added methods vstackSparseMatrices, extractRows, isEqualTo, clearColumn.
    29.08.12, 5.70 revised (fk) Added methods addNew, copyNew, sub, subNew.
    07.02.08, 5.60 revised (mn) Added methods deleteEntry() and deleteColumn().
    23.02.07, 5.50 revised (mn) Renamed stiff entries i and j to row and column.
    11.01.07, 5.40 revised (ah) Added method multQuadratic().
    09.11.06, 5.30 revised (fk) Added method deleteRow(int).
    12.09.06, 5.20 revised (mn) Added methods add(), clear(), multScalar() and concatMatrices().
    12.08.06, 5.10 revised (kh) Matrix multiplication added. Vector multiplication methods renamed.
    08.08.06, 5.00 revised (mn) Added support for non-square matrices.
    16.10.05, 4.00 revised (jh) Added methods transpose and toPdMatrix.
    10.03.05, 3.00 revised (ep) Extracted from PnStiffMatrix.
    11.03.03, 2.30 revised (kh) Static methods for matrix vector multiplication add.
    20.12.01, 2.20 revised (ep) Internationalization.
    08.11.00, 2.10 revised (kp) Number formatting replaced with PuString from Fmt.
    03.09.99, 2.00 revised (kp) Method split in subclasses.
    00.00.98, 1.00 created (kp)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `USE_LARGER_BUFFER` Flag, whether the buffer should enlarged dynamically.

    - ### Fields inherited from class jv.object.PsObject

      `HAS_BOUNDARY_PANEL, HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, IS_SELECTED, IS_USED, NUM_TAGS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PnSparseMatrix()` Constructor.
    `PnSparseMatrix(int iSize, int jSize)` Constructor with initial matrix sizes.
    `PnSparseMatrix(int iSize, int jSize, int bufferSize)` Constructor with initial matrix sizes and buffer size.
    `PnSparseMatrix(PdMatrix m)` Create a sparse Matrix from a PdMatrix.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(PnSparseMatrix m)` Add another sparse matrix to this matrix.
    `void` | `add(PnSparseMatrix m1, PnSparseMatrix m2)` Set this = m1+m2.
    `void` | `addDiagonal(double d)` Add the given value to every diagonal element of the matrix.
    `void` | `addDiagonal(PdVector diag)` Add a given diagonal matrix to this.
    `void` | `addEntry(int i, int j, double value)` Add value to the entry (i, j) of this matrix.
    `static PnSparseMatrix` | `addNew(PnSparseMatrix A, PnSparseMatrix B)` Return a new matrix that is the sum of A and B.
    `void` | `appendEntry(int i, int j, double value)` Appends an entry to row i.
    `void` | `clear()` Set all elements of the matrix to 0.
    `void` | `clearColumn(int colInd)` Set all entries in the specified column to 0.
    `void` | `clearRow(int rowInd)` Set all entries in specified row to 0.
    `void` | `compress()` Compress this stiff matrix that only values not equal zero remain.
    `void` | `concatMatrices(PnSparseMatrix ma, PnSparseMatrix mb, PnSparseMatrix mc, PnSparseMatrix md)` Concatenates 4 matrices to a bigger one of the form this = ((ma, mb), (mc, md)).
    `void` | `copy(PnSparseMatrix A)` Copy the sparse matrix A into this.
    `static PnSparseMatrix` | `copyNew(PnSparseMatrix A)` Return a copy of the argument matrix A.
    `void` | `deleteColumn(int col)` Delete the col-th column from the sparse matrix.
    `void` | `deleteRow(int i)` Delete the i-th row from the sparse matrix.
    `static PnSparseMatrix` | `extractRows(PnSparseMatrix sA, PiVector rowIndices)` Extract a given set of rows of a given sparse matrix and form a new sparse matrix out of these rows.
    `int` | `getColIndex(int i, int j)` Get the index of the column for the j.th entry in the i.th row.
    `PiVector[]` | `getColIndices()` Get an array with the column indices of the entries in the matrix.
    `PiVector` | `getColIndices(int i)` Get the column indices of the i.th row of the matrix.
    `int` | `getDiagIndex(int n)` Get the index of the n-th diagonal element.
    `PdVector[]` | `getEntries()` Get the array with all non-zero entries of the matrix.
    `PdVector` | `getEntries(int i)` Get the i.th row of the matrix.
    `double` | `getEntry(int i, int j)` Get the (i,j) entry of the matrix.
    `double` | `getEntrySparse(int i, int jInd)` Get the entry in row i at position jInd in the stiffness array.
    `int` | `getIndex(int aLine, int anIndex)` For given component s[aLine][aColumn] of the full matrix s this method finds the position in the index vector m_sindx[aLine] of the row aLine which refers to the full matrix component.
    `int` | `getNumCols()` Get number of columns of full matrix.
    `PiVector` | `getNumEntries()` Get the number of non-zero entries for all rows.
    `int` | `getNumEntries(int i)` Get the number of non-zero entries in the i.th row.
    `int` | `getNumRows()` Get number of rows of full matrix.
    `boolean` | `isEqualTo(PnSparseMatrix sA, double epsilon)` Check whether this matrix equals the given sparse matrix up to specified precision.
    `boolean` | `isSquare()` Whether numRows == numColumns.
    `PdVector` | `leftMultMatrix(PdVector out, PdVector in)` Multiply this matrix with vector and fill output vector, `out = this*in.`
    `PdVector` | `leftMultVector(PdVector in, PdVector out)` Deprecated.
    `PdVector` | `leftMultVector(PdVector in, PdVector out, int dim)` Compute out=in*smat.
    `static PdVector` | `leftMultVector(PnSparseMatrix smat, PdVector in, PdVector out)` Compute out=in*smat.
    `static PdVector` | `leftMultVector(PnSparseMatrix smat, PdVector in, PdVector out, int dim)` Compute out=in*smat.
    `static PnSparseMatrix` | `multMatrices(PnSparseMatrix left, PnSparseMatrix right, PnSparseMatrix out)` Multiply two sparse matrices, out = left.right.
    `double` | `multQuadratic(PdVector left, PdVector right)` Compute left^T*this*right.
    `void` | `multScalar(double scalar)` Multiply the matrix by a scalar value.
    `static PnSparseMatrix` | `multScalar(PnSparseMatrix smat, double scalar)` Multiply each entry of the matrix by a scalar value.
    `void` | `removeZeros(double eps)` Remove entries which are 0 up to a given tolerance.
    `PdVector` | `rightMultMatrix(PdVector out, PdVector in)` Multiply this matrix with vector and fill output vector, `out = in*this.`
    `PdVector` | `rightMultVector(PdVector in, PdVector out)` Deprecated.
    `PdVector` | `rightMultVector(PdVector in, PdVector out, int dim)` Compute out=smat*in.
    `static PdVector` | `rightMultVector(PnSparseMatrix smat, PdVector in, PdVector out)` Compute out=smat*in.
    `static PdVector` | `rightMultVector(PnSparseMatrix smat, PdVector in, PdVector out, int dim)` Compute out=smat*in.
    `void` | `setEntry(int i, int j, double value)` Set the entry (i, j) to a specific value.
    `void` | `setEntrySparse(int i, int jInd, double value)` Set the entry in row i at position jInd in the stiffness array.
    `void` | `setNumEntries(int i, int numEntries)` Set number of non-zero entries in row i.
    `void` | `setRow(int rowInd, int numEntries, PiVector colIndex, PdVector stiff)` Set a row of the matrix.
    `void` | `setSize(int size)` Set number of rows and number of columns to size.
    `void` | `setSize(int iSize, int jSize)` Set size of the matrix.
    `void` | `setSize(int numRows, int numCols, int bufferSize)` Set size and buffer of the matrix.
    `void` | `sortEntries()` Sort the sparse arrays (representing the rows) by their column indices.
    `void` | `sub(PnSparseMatrix m)` Subtract another sparse matrix from this matrix.
    `static PnSparseMatrix` | `subNew(PnSparseMatrix A, PnSparseMatrix B)` Return a new matrix A-B.
    `PdMatrix` | `toPdMatrix()` Convert the sparse matrix into a dense PdMatrix.
    `java.lang.String` | `toShortString()` Create a full matrix and print all components in a short multi-line string representation.
    `java.lang.String` | `toString()` Create a full matrix and print all components in a multi-line string representation.
    `void` | `transpose()` Transpose this sparse matrix.
    `void` | `transpose(PnSparseMatrix transpose)` Transpose a sparse matrix.
    `PnSparseMatrix` | `transposeNew()` Transpose a sparse matrix.
    `static PnSparseMatrix` | `transposeNew(PnSparseMatrix pm)` Transpose the sparse matrix.
    `void` | `validate()` Ensures, that the matrix is in a valid state.
    `static PnSparseMatrix` | `vstackSparseMatrices(PnSparseMatrix[] sA)` Vertically stack all given matrices into a single sparse matrix.

    - ### Methods inherited from class jv.object.PsObject

      `addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, init, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, setTag, update, updatePanels`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### USE_LARGER_BUFFER

          public static final boolean USE_LARGER_BUFFER

      Flag, whether the buffer should enlarged dynamically.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### PnSparseMatrix

          public PnSparseMatrix()

      Constructor.

    - #### PnSparseMatrix

          public PnSparseMatrix(int iSize,
                                int jSize)

      Constructor with initial matrix sizes.

    - #### PnSparseMatrix

          public PnSparseMatrix(int iSize,
                                int jSize,
                                int bufferSize)

      Constructor with initial matrix sizes and buffer size. Each row is assured to have at least bufferSize entries (some of them are possibly invisible from outside). The methods appendEntry() and addEntry() use these virtual entries for not reallocate memory each time.

    - #### PnSparseMatrix

          public PnSparseMatrix(PdMatrix m)

      Create a sparse Matrix from a PdMatrix. Only values greater than PuMath.EPS are used.

  - ### Method Detail

    - #### getNumRows

          public int getNumRows()

      Get number of rows of full matrix.
      Specified by:
        `getNumRows` in interface `PdMatrixIf`

    - #### getNumCols

          public int getNumCols()

      Get number of columns of full matrix.
      Specified by:
        `getNumCols` in interface `PdMatrixIf`

    - #### setSize

          public void setSize(int iSize,
                              int jSize)

      Set size of the matrix.

    - #### setSize

          public void setSize(int numRows,
                              int numCols,
                              int bufferSize)

      Set size and buffer of the matrix. This method assures that each row has at least bufferSize entries (some of them are possibly invisible from outside). The methods appendEntry() and addEntry() use these virtual entries for not reallocate memory each time.
      Version:
        13.09.06, 1.10 revised (mn) Added bufferSize parameter.

    - #### setSize

          public void setSize(int size)

      Set number of rows and number of columns to size.

    - #### setNumEntries

          public void setNumEntries(int i,
                                    int numEntries)

      Set number of non-zero entries in row i.

    - #### getEntries

          public PdVector[] getEntries()

      Get the array with all non-zero entries of the matrix.

    - #### getEntries

          public PdVector getEntries(int i)

      Get the i.th row of the matrix.

    - #### getEntrySparse

          public double getEntrySparse(int i,
                                       int jInd)

      Get the entry in row i at position jInd in the stiffness array. The column position of this entry can be obtained by getColIndices(i).
      Version:
        8.5.07, 2.00 revised (mn) Renamed to getEntrySparse().

    - #### getEntry

          public double getEntry(int i,
                                 int j)

      Get the (i,j) entry of the matrix.
      Specified by:
        `getEntry` in interface `PdMatrixIf`

    - #### getNumEntries

          public PiVector getNumEntries()

      Get the number of non-zero entries for all rows.

    - #### getNumEntries

          public int getNumEntries(int i)

      Get the number of non-zero entries in the i.th row.

    - #### getColIndices

          public PiVector[] getColIndices()

      Get an array with the column indices of the entries in the matrix.

    - #### getColIndices

          public PiVector getColIndices(int i)

      Get the column indices of the i.th row of the matrix.

    - #### getColIndex

          public int getColIndex(int i,
                                 int j)

      Get the index of the column for the j.th entry in the i.th row.

    - #### setRow

          public void setRow(int rowInd,
                             int numEntries,
                             PiVector colIndex,
                             PdVector stiff)

      Set a row of the matrix.

    - #### isSquare

          public boolean isSquare()

      Whether numRows == numColumns.
      Specified by:
        `isSquare` in interface `PdMatrixIf`

    - #### setEntry

          public void setEntry(int i,
                               int j,
                               double value)

      Set the entry (i, j) to a specific value.
      Note: This methods do a linear search through the matrix row i. If no entry (i, j) was found, then a new entry will be appended to row i. The entries in this row are then not necessarily sorted by their column index. Call validate() to ensure a valid state of the matrix.
      Specified by:
        `setEntry` in interface `PdMatrixIf`

    - #### setEntrySparse

          public void setEntrySparse(int i,
                                     int jInd,
                                     double value)

      Set the entry in row i at position jInd in the stiffness array. The column position of this entry can be obtained by getColIndices(i).
      Version:
        8.5.07, 1.00 created (mn)

    - #### addEntry

          public void addEntry(int i,
                               int j,
                               double value)

      Add value to the entry (i, j) of this matrix.
      The matrix rows are possibly not sorted after a call of this method. Call validate() to ensure a valid state of the matrix.
      Specified by:
        `addEntry` in interface `PdMatrixIf`

    - #### copy

          public void copy(PnSparseMatrix A)

      Copy the sparse matrix A into this.
      Parameters:
        `A` -

    - #### copyNew

          public static PnSparseMatrix copyNew(PnSparseMatrix A)

      Return a copy of the argument matrix A.
      Returns:
        A copy of the argument matrix A.
      Author:
        Felix Kaelberer
      Version:
        29.08.2012, 1.00 created (fk)

    - #### addNew

          public static PnSparseMatrix addNew(PnSparseMatrix A,
                                              PnSparseMatrix B)

      Return a new matrix that is the sum of A and B. Both matrices (A and B) must be valid.
      Returns:
        A new matrix that is the sum of A and B.
      Author:
        Felix Kaelberer
      Version:
        29.08.2012, 1.00 created (fk)

    - #### subNew

          public static PnSparseMatrix subNew(PnSparseMatrix A,
                                              PnSparseMatrix B)

      Return a new matrix A-B. Both matrices (A and B) must be valid.
      Returns:
        A new matrix M = A - B.
      Author:
        Felix Kaelberer
      Version:
        29.08.2012, 1.00 created (fk)

    - #### compress

          public void compress()

      Compress this stiff matrix that only values not equal zero remain.

    - #### toPdMatrix

          public PdMatrix toPdMatrix()

      Convert the sparse matrix into a dense PdMatrix.
      Returns:
        PdMatrix of the sparse matrix

    - #### getIndex

          public int getIndex(int aLine,
                              int anIndex)

      For given component s[aLine][aColumn] of the full matrix s this method finds the position in the index vector m_sindx[aLine] of the row aLine which refers to the full matrix component. If position is not found, then the component is added to the index vector by appending the value aColumn.

      This method is the central method for handling the sparse matrix representation.

      The matrix rows are possibly not sorted after a call of this method. Call validate() to ensure a valid state of the matrix.

      Version:
        03.09.06, 1.20 revised (kh) Method now calls appendEntry to allocate now memory.
        08.08.06, 1.10 revised (mn) Used PdVector.getIndexOf().
        15.06.03, 1.00 revised (kh) Set public.

    - #### appendEntry

          public void appendEntry(int i,
                                  int j,
                                  double value)

      Appends an entry to row i.
      Note: This method will not check if there is already an entry j in row i. Furthermore, row i will not be sorted by column indices. Call validate() to ensure a valid state of the matrix.
      Version:
        30.08.06, 2.00 revised (kh) renamed from addEntry to appendEntry.

    - #### toString

          public java.lang.String toString()

      Create a full matrix and print all components in a multi-line string representation.
      Overrides:
        `toString` in class `PsObject`
      Version:
        08.08.06, 1.10 revised (mn) Used toPdMatrix() for full matrix representation.

    - #### toShortString

          public java.lang.String toShortString()

      Create a full matrix and print all components in a short multi-line string representation.
      Version:
        12.09.06, 1.10 created (mn)

    - #### rightMultVector

          public PdVector rightMultVector(PdVector in,
                                          PdVector out,
                                          int dim)

      Compute out=smat*in. The arrays in and out must have length = dim*(dim of smat). The array in usually contains the position of vertices, listing all coordinates of one vertex before the next. Setting dim = dim of vertices allows to multiply each coordinate of the vertices with smat.

      If the vector out is null, a new vector is created.

      Author:
        Klaus Hildebrandt
      Version:
        11.03.03, 1.00 created (kh)

    - #### rightMultVector

          public PdVector rightMultVector(PdVector in,
                                          PdVector out)

      Deprecated.
      Compute out=smat*in. If the vector out is null, a new vector is created.
      Author:
        Klaus Hildebrandt
      Version:
        11.03.03, 1.00 created (kh)

    - #### leftMultMatrix

          public PdVector leftMultMatrix(PdVector out,
                                         PdVector in)

      Description copied from interface: `PdMatrixIf`
      Multiply this matrix with vector and fill output vector, `out = this*in.`. Matrix need not be square. Input vector must have same size as number of columns of this matrix. Method modifies size of output vector to number of rows of this matrix. If output vector is null then it is created.
      Specified by:
        `leftMultMatrix` in interface `PdMatrixIf`

    - #### rightMultVector

          public static PdVector rightMultVector(PnSparseMatrix smat,
                                                 PdVector in,
                                                 PdVector out,
                                                 int dim)

      Compute out=smat*in. If the vector out is null, a new vector is created.
      Author:
        Klaus Hildebrandt
      Version:
        08.08.06, 2.00 revised (mn) Added support for rectangular matrices.
        11.03.03, 1.00 created (kh)

    - #### rightMultVector

          public static PdVector rightMultVector(PnSparseMatrix smat,
                                                 PdVector in,
                                                 PdVector out)

      Compute out=smat*in. If the vector out is null, a new vector is created.
      Author:
        Klaus Hildebrandt
      Version:
        11.03.03, 1.00 created (kh)

    - #### leftMultVector

          public static PdVector leftMultVector(PnSparseMatrix smat,
                                                PdVector in,
                                                PdVector out,
                                                int dim)

      Compute out=in*smat. The arrays in and out must have `length >= dim*(dim of smat)`. The array in usually contains the position of vertices, listing all coordinates of one vertex before the next. Setting dim equal to dim of vertices allows to multiply each coordinate of the vertices with smat.

      If the vector out is null, a new vector is created.

      Author:
        Klaus Hildebrandt
      Version:
        08.08.06, 2.00 revised (mn) Added support for rectangular matrices.
        11.03.03, 1.00 created (kh)

    - #### leftMultVector

          public PdVector leftMultVector(PdVector in,
                                         PdVector out,
                                         int dim)

      Compute out=in*smat. If the vector out is null, a new vector is created.
      Author:
        Klaus Hildebrandt
      Version:
        11.03.03, 1.00 created (kh)

    - #### leftMultVector

          public PdVector leftMultVector(PdVector in,
                                         PdVector out)

      Deprecated.
      Compute out=in*smat. If the vector out is null, a new vector is created.
      Author:
        Klaus Hildebrandt
      Version:
        11.03.03, 1.00 created (kh)

    - #### rightMultMatrix

          public PdVector rightMultMatrix(PdVector out,
                                          PdVector in)

      Description copied from interface: `PdMatrixIf`
      Multiply this matrix with vector and fill output vector, `out = in*this.`. Matrix need not be square. Input vector must have same size as number of rows of this matrix. Method modifies size of output vector to number of columns of this matrix. If output vector is null then it is created.
      Specified by:
        `rightMultMatrix` in interface `PdMatrixIf`

    - #### leftMultVector

          public static PdVector leftMultVector(PnSparseMatrix smat,
                                                PdVector in,
                                                PdVector out)

      Compute out=in*smat. If the vector out is null, a new vector is created.
      Author:
        Klaus Hildebrandt
      Version:
        11.03.03, 1.00 created (kh)

    - #### getDiagIndex

          public int getDiagIndex(int n)

      Get the index of the n-th diagonal element.
      Parameters:
        `n` -
      Returns:
        index

    - #### transposeNew

          public PnSparseMatrix transposeNew()

      Transpose a sparse matrix.
      Returns:
        a new PnSparseMatrix instance, which is transpose of the actual matrix.
      Version:
        30.08.06, 2.10 revised (kh) Renamed from transpose to transposeNew. 08.08.06, 2.00 revised (mn) Adapted for rectangular matrices.

    - #### transpose

          public void transpose(PnSparseMatrix transpose)

      Transpose a sparse matrix. The given matrix "transpose" is transposed and stored in this.
      Parameters:
        `transpose` - Matrix to be transposed.
      Version:
        30.08.06, 1.00 created (kh) Adapted for rectangular matrices.

    - #### transpose

          public void transpose()

      Transpose this sparse matrix.
      Specified by:
        `transpose` in interface `PdMatrixIf`

    - #### multMatrices

          public static PnSparseMatrix multMatrices(PnSparseMatrix left,
                                                    PnSparseMatrix right,
                                                    PnSparseMatrix out)

      Multiply two sparse matrices, out = left.right.
      Returns:
        the matrix out is returned
      Version:
        30.08.06, 1.00 created (kh)

    - #### validate

          public void validate()

      Ensures, that the matrix is in a valid state. I.e. for each row, the entries are sorted by their column index. Entries with the same column index will be summed up. Entries with a ColIndex out of range will be removed.
      Author:
        Matthias Nieser
      Version:
        12.09.05, 1.10 revised (mn) Remove entries with ColIndex out of range.
        23.08.06, 1.00 created (mn)

    - #### removeZeros

          public void removeZeros(double eps)

      Remove entries which are 0 up to a given tolerance.
      Author:
        Matthias Nieser
      Version:
        26.01.11, 1.00 created (mn)

    - #### transposeNew

          public static PnSparseMatrix transposeNew(PnSparseMatrix pm)

      Transpose the sparse matrix.
      Parameters:
        `pm` - the sparse matrix to transpose
      Returns:
        a new PnSparseMatrix instance of the transpose matrix
      Version:
        30.08.06, 2.00 revised (kh) Renamed from transpose to transposeNew.

    - #### add

          public void add(PnSparseMatrix m)

      Add another sparse matrix to this matrix. Both matrices (this and m) have to be valid. Call validate() before.
      Version:
        29.08.2012, 1.00 created (fk)

    - #### sub

          public void sub(PnSparseMatrix m)

      Subtract another sparse matrix from this matrix. Both matrices (this and m) have to be valid.
      Version:
        29.08.2012, 1.00 created (fk)

    - #### add

          public void add(PnSparseMatrix m1,
                          PnSparseMatrix m2)

      Set this = m1+m2. Both matrices (m1 and m2) have to be valid. Call validate() before.
      Author:
        Matthias Nieser
      Version:
        12.09.06, 1.00 created (mn)

    - #### addDiagonal

          public void addDiagonal(double d)

      Add the given value to every diagonal element of the matrix. Works only for square matrices.
      Version:
        13.09.06, 1.10 revised (mn) Replaced code by a call of addEntry().

    - #### addDiagonal

          public void addDiagonal(PdVector diag)

      Add a given diagonal matrix to this. Works only for square matrices.
      Parameters:
        `diag` - Diagonal entries of the matrix.
      Author:
        Matthias Nieser
      Version:
        13.09.06, 1.00 created (mn)

    - #### multScalar

          public void multScalar(double scalar)

      Multiply the matrix by a scalar value.
      Specified by:
        `multScalar` in interface `PdMatrixIf`
      Author:
        Matthias Nieser
      Version:
        12.09.06, 1.00 created (mn)

    - #### clear

          public void clear()

      Set all elements of the matrix to 0.
      Specified by:
        `clear` in interface `PdMatrixIf`

    - #### concatMatrices

          public void concatMatrices(PnSparseMatrix ma,
                                     PnSparseMatrix mb,
                                     PnSparseMatrix mc,
                                     PnSparseMatrix md)

      Concatenates 4 matrices to a bigger one of the form this = ((ma, mb), (mc, md)).

      The matrices (mb, md) or (mc, md) may be null if only two matrices should be concatenated.

      Author:
        Matthias Nieser
      Version:
        12.09.06, 1.00 created (mn)

    - #### deleteRow

          public void deleteRow(int i)

      Delete the i-th row from the sparse matrix.
      Parameters:
        `i` - Row index.
      Author:
        Felix Kälberer
      Version:
        02.05.17, 1.01 revised (poe) fixed off-by-one error. 09.11.06, 1.00 created (fk)

    - #### deleteColumn

          public void deleteColumn(int col)

      Delete the col-th column from the sparse matrix.
      Parameters:
        `col` - Column index.
      Author:
        Matthias Nieser
      Version:
        07.02.08, 1.00 created (mn)

    - #### multQuadratic

          public double multQuadratic(PdVector left,
                                      PdVector right)

      Compute left^T*this*right. The matrix is interpreted as a quadratic form.
      Specified by:
        `multQuadratic` in interface `PdMatrixIf`
      Parameters:
        `left` - The left argument.
        `right` - The right argument.
      Returns:
        left^T*this*right.

    - #### multScalar

          public static PnSparseMatrix multScalar(PnSparseMatrix smat,
                                                  double scalar)

      Multiply each entry of the matrix by a scalar value.
      Returns:
        the given matrix smat is returned.
      Version:
        30.10.06, 1.00 created (kh)

    - #### sortEntries

          public void sortEntries()

      Sort the sparse arrays (representing the rows) by their column indices.
      Version:
        30.10.06, 1.00 created (kh)

    - #### clearRow

          public void clearRow(int rowInd)

      Set all entries in specified row to 0.
      Parameters:
        `rowInd` - A valid row Index
      Version:
        06.02.08, 1.00 created (mn)

    - #### clearColumn

          public void clearColumn(int colInd)

      Set all entries in the specified column to 0.
      Parameters:
        `colInd` - A valid column index.
      See Also:
        `clearRow(int)`
      Author:
        Konstantin Poelke
      Version:
        09.05.2017, 1.00 created (poe)

    - #### isEqualTo

          public boolean isEqualTo(PnSparseMatrix sA,
                                   double epsilon)

      Check whether this matrix equals the given sparse matrix up to specified precision. Equality means same dimension and same entries, up to a specified epsilon in the entry values.
      Parameters:
        `sA` - A `PnSparseMatrix`
        `epsilon` - A precision value up to which the Euclidean (L2-)norm of the difference vector of the entries in each row are considered equal.
      Returns:
        true, if this matrix has the same dimensions and entries as given matrix, false otherwise.
      Author:
        Konstantin Poelke
      Version:
        08.05.2017, 1.00 created (poe)

    - #### vstackSparseMatrices

          public static PnSparseMatrix vstackSparseMatrices(PnSparseMatrix[] sA)

      Vertically stack all given matrices into a single sparse matrix.

      For completeness, one should add a corresponding hstack (horizontal stack) method to this class.

      Parameters:
        `sA` - A list of sparse matrices A1,...,Ak, all with the same number of columns n, but possible different number of rows m_i.
      Returns:
        The sparse matrix A = (A1 ... Ak)^T of dimension (m_1+...+m_k, n).
      See Also:
        `concatMatrices(PnSparseMatrix, PnSparseMatrix, PnSparseMatrix, PnSparseMatrix)`
      Author:
        Konstantin Poelke
      Version:
        12.04.2017, created (poe)

    - #### extractRows

          public static PnSparseMatrix extractRows(PnSparseMatrix sA,
                                                   PiVector rowIndices)

      Extract a given set of rows of a given sparse matrix and form a new sparse matrix out of these rows.
      Parameters:
        `sA` - A `PnSparseMatrix`
        `rowIndices` - A `PiVector` containing the row indices of the rows to be extracted. In particular, each entry must by an integer less then the number of rows of sA.
      Returns:
        A new `PnSparseMatrix` object, whose number of rows equals the size of rowIndices and whose number of columns equals the number of columns of sA.
      Author:
        Konstantin Poelke
      Version:
        08.05.2017, 1.00 created (poe)

"

The software JavaView? is copyright protected. All Rights Reserved.
"