@PublicationReference(author="Wikipedia", title="Sparse Matrix / Yale format", type=WebPage, year=2013, url="http://en.wikipedia.org/wiki/Sparse_matrix#Yale_format") public class ParallelSparseMatrix extends SparseMatrix
columnIndices, firstIndicesForRows, values
Modifier | Constructor and Description |
---|---|
protected |
ParallelSparseMatrix()
This should never be called by anything or anyone other than Java's
serialization code.
|
|
ParallelSparseMatrix(DenseMatrix d,
int numThreads)
Creates a new sparse matrix with the same dimensions and data as d
(performs a deep copy).
|
|
ParallelSparseMatrix(DiagonalMatrix d,
int numThreads)
Creates a new sparse matrix with the same dimensions and data as d
(performs a deep copy).
|
|
ParallelSparseMatrix(int numRows,
int numCols,
int numThreads)
Creates a new parallel sparse matrix with the specified number of rows
and columns.
|
|
ParallelSparseMatrix(ParallelSparseMatrix m)
Creates a new sparse matrix with the same dimensions and data as m
(performs a deep copy).
|
|
ParallelSparseMatrix(SparseMatrix m,
int numThreads)
Creates a new sparse matrix with the same dimensions and data as m
(performs a deep copy).
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkSolveDimensions(Matrix b)
Checks that the input matrix has the same numRows as this's numRows
(otherwise, there can be no soluation for Ax = b).
|
protected void |
checkSolveDimensions(Vector b)
Checks that the input vector has the same dimensionality as this's
numRows (otherwise, there can be no solution for Ax = b).
|
protected void |
checkSubmatrixRange(int minRow,
int maxRow,
int minCol,
int maxCol)
Helper method checks that the input submatrix range is acceptable for
this matrix, including that the max is greater than or equal to the min.
|
Matrix |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
Matrix |
dotTimes(Matrix other)
Element-wise multiplication of
this and other |
void |
dotTimesEquals(Matrix other)
Inline element-wise multiplication of
this and
other |
Matrix |
minus(Matrix other)
Arithmetic subtraction of
other from this |
void |
minusEquals(Matrix other)
Inline arithmetic subtraction of
other from
this |
Matrix |
plus(Matrix other)
Arithmetic addition of
this and other |
void |
plusEquals(Matrix other)
Inline arithmetic addition of
this and other |
Vector |
preTimes(Vector vector)
Package-private method that puts the vector * matrix code in the matrix
class instead of in the vector class (why should vectors know the
internals of matrices?).
|
void |
scaledPlusEquals(double scaleFactor,
Matrix other)
Inline arithmetic addition of
this and other after
element-wise scaling of other by scaleFactor . |
Vector |
times(DenseVector vector)
Type-specific version of times for combining whatever type this is with
the input dense vector.
|
Matrix |
times(Matrix other)
Matrix multiplication of
this and matrix ,
operates like the "* " operator in Matlab |
Vector |
times(SparseVector vector)
Type-specific version of times for combining whatever type this is with
the input sparse vector.
|
Vector |
times(Vector vector)
Returns the column vector from the equation
return = this * vector
|
java.lang.String |
toString(java.text.NumberFormat format)
Converts the vector to a
String , using the given formatter. |
compress, convertFromVector, convertToVector, decompress, dotTimesEquals, dotTimesEquals, dotTimesEquals, get, getColumn, getElement, getEntryCount, getMatrixFactory, getNonZeroValueIterator, getNonZeroValueIterator, getNumColumns, getNumRows, getRow, getSubMatrix, identity, inverse, isCompressed, isSparse, isSquare, isSymmetric, isZero, isZero, iterator, logDeterminant, minusEquals, minusEquals, minusEquals, normFrobenius, normFrobeniusSquared, plusEquals, plusEquals, plusEquals, preTimes, preTimes, preTimes, pseudoInverse, rank, scaledPlusEquals, scaledPlusEquals, scaledPlusEquals, scaleEquals, set, setElement, solve, solve, sumOfColumns, sumOfRows, times, times, times, transpose
assertMultiplicationDimensions, assertSameDimensions, checkMultiplicationDimensions, checkSameDimensions, decrement, decrement, dotDivide, dotDivideEquals, equals, equals, getColumnInto, getRowInto, hashCode, increment, increment, isSymmetric, pseudoInverse, rank, setColumn, setRow, setSubMatrix, toArray, trace, valuesAsList
negative, negativeEquals, scale, scaledMinus, scaledMinusEquals, scaledPlus, zero
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
negative, negativeEquals, scale, scaledMinus, scaledMinusEquals, scaledPlus, zero
public ParallelSparseMatrix(int numRows, int numCols, int numThreads)
numRows
- The number of rows in the matrixnumCols
- The number of columns in the matrixnumThreads
- The number of threads to use for parallelized
operationspublic ParallelSparseMatrix(ParallelSparseMatrix m)
m
- The sparse matrix to copypublic ParallelSparseMatrix(SparseMatrix m, int numThreads)
m
- The sparse matrix to copynumThreads
- The number of threads to use for parallelized
operationspublic ParallelSparseMatrix(DenseMatrix d, int numThreads)
d
- The dense matrix to copynumThreads
- The number of threads to use for parallelized
operationspublic ParallelSparseMatrix(DiagonalMatrix d, int numThreads)
d
- The diagonal matrix to copynumThreads
- The number of threads to use for parallelized
operationsprotected ParallelSparseMatrix()
public final Matrix clone()
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.
NOTE: This does not affect this's format. The cloned matrix is in the
same format as this.
NOTE: This does not affect this's format. The cloned matrix is in the
same format as this.clone
in interface Matrix
clone
in interface Vectorizable
clone
in interface Ring<Matrix>
clone
in interface CloneableSerializable
clone
in class SparseMatrix
public Vector times(SparseVector vector)
times
in class SparseMatrix
vector
- A sparse vector to multiply with thispublic Vector times(DenseVector vector)
times
in class SparseMatrix
vector
- A dense vector to multiply with thispublic final Matrix plus(Matrix other)
Ring
this
and other
public final Matrix minus(Matrix other)
Ring
other
from this
public final Matrix dotTimes(Matrix other)
Ring
this
and other
public final void plusEquals(Matrix other)
Ring
this
and other
plusEquals
in interface Ring<Matrix>
plusEquals
in class AbstractMatrix
other
- object to add to this
public final void scaledPlusEquals(double scaleFactor, Matrix other)
Ring
this
and other
after
element-wise scaling of other
by scaleFactor
.
If this is x, other is y, and scaleFactor is a, then this method is
equivalent to x += a * y. It is typically a more efficient way of doing
this.plusEquals(other.scale(scaleFactor))
since it can avoid
intermediate object creation.scaledPlusEquals
in interface Ring<Matrix>
scaledPlusEquals
in class AbstractMatrix
scaleFactor
- The scale factor to multiply by the elements of other before
adding to the elements of this.other
- Object to scale and then add to this.public final void minusEquals(Matrix other)
Ring
other
from
this
minusEquals
in interface Ring<Matrix>
minusEquals
in class AbstractMatrix
other
- object to subtract from this
public final void dotTimesEquals(Matrix other)
Ring
this
and
other
dotTimesEquals
in interface Ring<Matrix>
dotTimesEquals
in class AbstractMatrix
other
- elements of other will be multiplied to the corresponding
elements of this
public final Matrix times(Matrix other)
Matrix
this
and matrix
,
operates like the "*
" operator in Matlabtimes
in interface Matrix
times
in class AbstractMatrix
other
- this.getNumColumns()==matrix.getNumRows()
this
and
matrix
, will this.getNumRows()
rows and
matrix.getNumColumns()
columnspublic final Vector times(Vector vector)
Matrix
times
in interface Matrix
times
in class AbstractMatrix
vector
- Vector by which to post-multiply this, must have the
same number of rows as thispublic final Vector preTimes(Vector vector)
vector
- The vector to pre-multiply this byDimensionalityMismatchException
- if the input vectors's dimensions
doesn't match this's numRows.protected final void checkSubmatrixRange(int minRow, int maxRow, int minCol, int maxCol)
minRow
- The minimum row to return (inclusive)maxRow
- The maximum row to return (inclusive)minCol
- The minimum column to return (inclusive)maxCol
- The maximum column to return (inclusive)java.lang.ArrayIndexOutOfBoundsException
- if the input range is illegal or
outside the bounds of this.protected final void checkSolveDimensions(Vector b)
b
- The RHS vectorjava.lang.IllegalArgumentException
- if the input's size doesn't match this's
numRowsprotected final void checkSolveDimensions(Matrix b)
b
- The RHS matrixjava.lang.IllegalArgumentException
- if the input's size doesn't match this's
numRowspublic final java.lang.String toString(java.text.NumberFormat format)
Matrix
String
, using the given formatter.format
- The number format to use.