public final class SparseMatrixUtils extends Object
SparseMatrix
.Modifier and Type | Method and Description |
---|---|
static int[] |
countEntriesInEachColumn(List<SparseMatrix.Entry> entries,
int nCols)
Counts the number of entries in each column.
|
static int[] |
countEntriesInEachRow(List<SparseMatrix.Entry> entries,
int nRows)
Counts the number of entries in each row.
|
static boolean |
equals(SparseMatrix A,
SparseMatrix B)
Checks if two SparseMatrixs are equal.
|
static int[] |
sortInColumnOrder(List<SparseMatrix.Entry> entries,
int nCols)
Sorts a list of sparse matrix entries in column order (row indices in the same row can be in
arbitrary order) in linear time.
|
static int[] |
sortInColumnOrder(SparseMatrix.Entry[] entries,
int nCols)
Sorts an array of sparse matrix entries in column order (row indices in the same row can be
in arbitrary order) in linear time.
|
static int[] |
sortInRowColumnOrder(List<SparseMatrix.Entry> entries,
int nRows,
int nCols,
boolean checkRange,
boolean checkDuplicate)
Sorts a list of sparse matrix entries in row-column order in linear time.
|
static int[] |
sortInRowColumnOrder(SparseMatrix.Entry[] entries,
int nRows,
int nCols,
boolean checkRange,
boolean checkDuplicate)
Sorts an array of sparse matrix entries in row-column order in linear time.
|
static int[] |
sortInRowOrder(List<SparseMatrix.Entry> entries,
int nRows)
Sorts a list of sparse matrix entries in row order (column indices in the same row can be in
arbitrary order) in linear time.
|
static int[] |
sortInRowOrder(SparseMatrix.Entry[] entries,
int nRows)
Sorts an array of sparse matrix entries in row order (column indices in the same row can be
in arbitrary order) in linear time.
|
static String |
toString(SparseMatrix A)
Returns a string representation of a SparseMatrix.
|
public static int[] sortInRowColumnOrder(List<SparseMatrix.Entry> entries, int nRows, int nCols, boolean checkRange, boolean checkDuplicate)
result[0]
contains the start index of the first row, result[1]
contains the start index of the
second row, etc. That means, the entries from entries[result[k-1]]
to
entries[result[k] - 1]
are entries in row k.entries
- the sparse matrix entries to be sortednRows
- the number of rows in the matrix (or the maximum possible row index)nCols
- the number of columns in the matrix (or the maximum possible column
index)checkRange
- true
if entry coordinates should be checked against rangecheckDuplicate
- true
if duplicates are NOT allowedpublic static int[] sortInRowColumnOrder(SparseMatrix.Entry[] entries, int nRows, int nCols, boolean checkRange, boolean checkDuplicate)
result[0]
contains the start index of the first row, result[1]
contains the
start index of the second row, etc. That means, the entries from entries[result[k-1]]
to entries[result[k] - 1]
are entries in row k.entries
- the sparse matrix entries to be sortednRows
- the number of rows of the matrix (or the maximum possible row index)nCols
- the number of columns of the matrix (or the maximum possible column
index)checkRange
- true
if entry coordinates should be checked against rangecheckDuplicate
- true
if duplicates are NOT allowedpublic static int[] sortInRowOrder(List<SparseMatrix.Entry> entries, int nRows)
result[0]
contains the start index of the first
row, result[1]
contains the start index of the second row, etc. That means, the
entries from entries[result[k-1]]
to entries[result[k] - 1]
are entries in
row k.entries
- the sparse matrix entries to be sortednRows
- the number of rows of the matrix (or the maximum row index)public static int[] sortInRowOrder(SparseMatrix.Entry[] entries, int nRows)
result[0]
contains the start index of the first
row, result[1]
contains the start index of the second row, etc. That means, the
entries from entries[result[k-1]]
to entries[result[k] - 1]
are entries in
row k.entries
- the sparse matrix entries to be sortednRows
- the number of rows of the matrix (or the maximum row index)public static int[] sortInColumnOrder(List<SparseMatrix.Entry> entries, int nCols)
result[0]
contains the start index of the first
column, result[1]
contains the start index of the second column, etc. That means, the
entries from entries[result[k-1]]
to entries[result[k] - 1]
are entries in
column k.entries
- the sparse matrix entries to be sortednCols
- the number of columns of the matrix (or the maximum column index)public static int[] sortInColumnOrder(SparseMatrix.Entry[] entries, int nCols)
result[0]
contains the start index of the
first column, result[1]
contains the start index of the second column, etc. That
means, the entries from entries[result[k-1]]
to entries[result[k] - 1]
are
entries in column k.entries
- the sparse matrix entries to be sortednCols
- the number of columns of the matrix (or the maximum column index)public static int[] countEntriesInEachRow(List<SparseMatrix.Entry> entries, int nRows)
entries
- the sparse matrix entriesnRows
- the number of rows of the matrix (or the maximum row index)counts[1]
stores the number of entries in the first row)public static int[] countEntriesInEachColumn(List<SparseMatrix.Entry> entries, int nCols)
entries
- the sparse matrix entriesnCols
- the number of columns of the matrix (or the maximum column index)counts[1]
stores the number of entries in the first column)public static String toString(SparseMatrix A)
A
- the sparse matrixString
representationpublic static boolean equals(SparseMatrix A, SparseMatrix B)
A
- one sparse matrixB
- another sparse matrixtrue
if A
and B
are equalCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.