Class AbstractDenseSemiringMatrix<T extends AbstractDenseSemiringMatrix<T,U,V>,U extends AbstractDenseSemiringVector<U,T,V>,V extends Semiring<V>>      
java.lang.Object
org.flag4j.arrays.backend.AbstractTensor<T,V[],V>
  
org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensor<T,V>
 
org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringMatrix<T,U,V>  
- Type Parameters:
- T- The type of this matrix.
- U- The type of the vector which is of similar type to- T.
- V- The type of the semiring the data of the matrix belong to.
- All Implemented Interfaces:
- Serializable,- MatrixMixin<T,,- T, - U, - V> - SemiringTensorMixin<T,,- T, - V> - TensorOverSemiring<T,- T, - V[], - V> 
- Direct Known Subclasses:
- AbstractDenseRingMatrix,- SemiringMatrix
public abstract class AbstractDenseSemiringMatrix<T extends AbstractDenseSemiringMatrix<T,U,V>,U extends AbstractDenseSemiringVector<U,T,V>,V extends Semiring<V>>      
extends AbstractDenseSemiringTensor<T,V>
implements MatrixMixin<T,T,U,V>    
The base class for all dense matrices whose elements are members of a 
Semiring.- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionfinal intThe number of columns in this matrix.final intThe number of rows in this matrix.Fields inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensorzeroElementFields inherited from class org.flag4j.arrays.backend.AbstractTensordata, rank, shape
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractDenseSemiringMatrix(Shape shape, V[] entries) Creates a tensor with the specified data and shape.
- 
Method SummaryModifier and TypeMethodDescriptionStacks matrices along rows.Augments a vector to this matrix.intGets the length of the data array which backs this matrix.flatten()Flattens this matrix to a row vector.flatten(int axis) Flattens this matrix along the specified axis.get(int row, int col) Gets the element of this matrix at this specifiedrowandcol.getCol(int colIdx, int rowStart, int rowEnd) Gets a specified column of this matrix betweenrowStart(inclusive) androwEnd(exclusive).getDiag(int diagOffset) Gets the elements of this matrix along the specified diagonal.getRow(int rowIdx, int colStart, int colEnd) Gets a specified row of this matrix betweencolStart(inclusive) andcolEnd(exclusive).getSlice(int rowStart, int rowEnd, int colStart, int colEnd) Gets a specified slice of this matrix.getTriL(int diagOffset) Extracts the lower-triangular portion of this matrix with a specified diagonal offset.getTriU(int diagOffset) Extracts the upper-triangular portion of this matrix with a specified diagonal offset.H()Computes the Hermitian transpose of this matrix.booleanChecks if a matrix is Hermitian.booleanisI()Checks if this matrix is the identity matrix.booleanChecks if this matrix is orthogonal.booleanChecks if a matrix is symmetric.booleanisTriL()Checks if this matrix is lower triangular.booleanisTriU()Checks if this matrix is upper triangular.protected abstract AbstractCooSemiringMatrix<?, T, ?, V> makeLikeCooMatrix(Shape shape, V[] entries, int[] rowIndices, int[] colIndices) Constructs a sparse COO matrix which is of a similar type as this dense matrix.abstract AbstractCsrSemiringMatrix<?, T, ?, V> makeLikeCsrMatrix(Shape shape, V[] entries, int[] rowPointers, int[] colIndices) Constructs a sparse CSR matrix which is of a similar type as this dense matrix.protected abstract UmakeLikeVector(Shape shape, V[] entries) Constructs a vector of a similar type as this matrix.protected abstract UmakeLikeVector(V[] entries) Constructs a vector of a similar type as this matrix.Computes the matrix multiplication between two matrices.Computes the matrix-vector multiplication of a vector with this matrix.multTranspose(T b) Multiplies this matrix with the transpose of thebtensor as if bythis.mult(b.T()).intnumCols()Gets the number of columns in this matrix.intnumRows()Gets the number of rows in this matrix.removeCol(int colIndex) Removes a specified column from this matrix.removeCols(int... colIndices) Removes a specified set of columns from this matrix.removeRow(int rowIndex) Removes a specified row from this matrix.removeRows(int... rowIndices) Removes a specified set of rows from this matrix.Sets an index of this matrix to the specified value.Sets a specified column of this matrix to a vector.Sets a specified column of this matrix to an array.Sets a specified row of this matrix to a vector.Sets a specified row of this matrix to an array.Sets a slice of this matrix to the specified values.setSliceCopy(T values, int rowStart, int colStart) Creates a copy of this matrix and sets a slice of the copy to the specified values.Sets the value of this matrix using a 2D array.Stacks matrices along columns.swapCols(int colIndex1, int colIndex2) Swaps specified columns in the matrix.swapRows(int rowIndex1, int rowIndex2) Swaps specified rows in the matrix.T()Computes the transpose of a tensor by exchanging the first and last axes of this tensor.AbstractCooSemiringMatrix<?, ?, ?, V> toCoo()Converts this matrix to an equivalent sparse COO matrix.AbstractCooSemiringMatrix<?, ?, ?, V> toCoo(double estimatedSparsity) Converts this matrix to an equivalent sparse COO matrix.AbstractCsrSemiringMatrix<?, ?, ?, V> toCsr()Converts this matrix to an equivalent sparse CSR matrix.AbstractCsrSemiringMatrix<?, ?, ?, V> toCsr(double estimatedSparsity) Converts this matrix to an equivalent sparse CSR matrix.abstract AbstractDenseSemiringTensor<?, V> toTensor()Converts this matrix to an equivalent tensor.abstract AbstractDenseSemiringTensor<?, V> Converts this matrix to an equivalent tensor with the specifiednewShape.toVector()Converts this matrix to an equivalent vector.tr()Computes the trace of this matrix.Methods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensoradd, addEq, argmax, argmin, copy, elemMult, get, getZeroElement, makeLikeCooTensor, max, min, reshape, set, setZeroElement, T, T, tensorDot, tensorTrMethods inherited from class org.flag4j.arrays.backend.AbstractTensorgetData, getRank, getShape, makeLikeTensor, reshape, sameShape, totalEntriesMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.flag4j.arrays.backend.MatrixMixinaccept, add, copy, div, elemMult, fib, getCol, getDiag, getRow, getShape, getTriL, getTriU, isDiag, isSquare, isTri, isVector, stack, sub, trace, vectorTypeMethods inherited from interface org.flag4j.arrays.backend.semiring_arrays.SemiringTensorMixinadd, addEq, isOnes, isZeros, makeEmptyDataArray, mult, multEq, prod, sumMethods inherited from interface org.flag4j.arrays.backend.semiring_arrays.TensorOverSemiringgetData, getRank, getShape, makeLikeTensor, tensorDot, tensorDot, tensorDot, tensorTr
- 
Field Details- 
numRowspublic final int numRowsThe number of rows in this matrix.
- 
numColspublic final int numColsThe number of columns in this matrix.
 
- 
- 
Constructor Details- 
AbstractDenseSemiringMatrixCreates a tensor with the specified data and shape.- Parameters:
- shape- Shape of this tensor.
- entries- Entries of this tensor. If this tensor is dense, this specifies all data within the tensor. If this tensor is sparse, this specifies only the non-zero data of the tensor.
 
 
- 
- 
Method Details- 
makeLikeVector
- 
makeLikeVector
- 
makeLikeCooMatrixprotected abstract AbstractCooSemiringMatrix<?,T, makeLikeCooMatrix?, V> (Shape shape, V[] entries, int[] rowIndices, int[] colIndices) Constructs a sparse COO matrix which is of a similar type as this dense matrix.- Parameters:
- shape- Shape of the COO matrix.
- entries- Non-zero data of the COO matrix.
- rowIndices- Non-zero row indices of the COO matrix.
- colIndices- Non-zero column indices of the COO matrix.
- Returns:
- A sparse COO matrix which is of a similar type as this dense matrix.
 
- 
makeLikeCsrMatrixpublic abstract AbstractCsrSemiringMatrix<?,T, makeLikeCsrMatrix?, V> (Shape shape, V[] entries, int[] rowPointers, int[] colIndices) Constructs a sparse CSR matrix which is of a similar type as this dense matrix.- Parameters:
- shape- Shape of the CSR matrix.
- entries- Non-zero data of the CSR matrix.
- rowPointers- Non-zero row pointers of the CSR matrix.
- colIndices- Non-zero column indices of the CSR matrix.
- Returns:
- A sparse CSR matrix which is of a similar type as this dense matrix.
 
- 
TComputes the transpose of a tensor by exchanging the first and last axes of this tensor.- Specified by:
- Tin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Overrides:
- Tin class- AbstractTensor<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - V extends Semiring<V>[], - V extends Semiring<V>> 
- Returns:
- The transpose of this tensor.
- See Also:
 
- 
numRowspublic int numRows()Gets the number of rows in this matrix.- Specified by:
- numRowsin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Returns:
- The number of rows in this matrix.
 
- 
numColspublic int numCols()Gets the number of columns in this matrix.- Specified by:
- numColsin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Returns:
- The number of columns in this matrix.
 
- 
dataLengthpublic int dataLength()Gets the length of the data array which backs this matrix.- Specified by:
- dataLengthin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Overrides:
- dataLengthin class- AbstractDenseSemiringTensor<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - V extends Semiring<V>> 
- Returns:
- The length of the data array which backs this matrix.
 
- 
getGets the element of this matrix at this specifiedrowandcol.- Specified by:
- getin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- row- Row index of the item to get from this matrix.
- col- Column index of the item to get from this matrix.
- Returns:
- The element of this matrix at the specified index.
 
- 
trComputes the trace of this matrix. That is, the sum of elements along the principle diagonal of this matrix. Same as MatrixMixin.trace().- Specified by:
- trin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Returns:
- The trace of this matrix.
- Throws:
- IllegalArgumentException- If this matrix is not square.
 
- 
isTriUpublic boolean isTriU()Checks if this matrix is upper triangular.- Specified by:
- isTriUin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Returns:
- trueis this matrix is upper triangular;- falseotherwise.
- See Also:
 
- 
isTriLpublic boolean isTriL()Checks if this matrix is lower triangular.- Specified by:
- isTriLin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Returns:
- trueis this matrix is lower triangular;- falseotherwise.
- See Also:
 
- 
isIpublic boolean isI()Checks if this matrix is the identity matrix. That is, checks if this matrix is square and contains only ones along the principle diagonal and zeros everywhere else.- Specified by:
- isIin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Returns:
- trueif this matrix is the identity matrix;- falseotherwise.
 
- 
multComputes the matrix-vector multiplication of a vector with this matrix.- Specified by:
- multin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- b- Vector in the matrix-vector multiplication.
- Returns:
- The result of multiplying this matrix with b.
- Throws:
- LinearAlgebraException- If the number of columns in this matrix do not equal the size of- b.
 
- 
multComputes the matrix multiplication between two matrices.- Specified by:
- multin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- b- Second matrix in the matrix multiplication.
- Returns:
- The result of matrix multiplying this matrix with matrix b.
- Throws:
- LinearAlgebraException- If- this.numCols() != b.numRows().
 
- 
multTransposeMultiplies this matrix with the transpose of thebtensor as if bythis.mult(b.T()). For large matrices, this method may, be noticeably faster than directly computing the transpose followed by the multiplication asthis.mult(b.T()).- Specified by:
- multTransposein interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- b- The second matrix in the multiplication and the matrix to transpose.
- Returns:
- The result of multiplying this matrix with the transpose of b.
 
- 
stackStacks matrices along columns.- Specified by:
- stackin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- b- Matrix to stack to this matrix.
- Returns:
- The result of stacking this matrix on top of the matrix b.
- Throws:
- IllegalArgumentException- If this matrix and matrix- bhave a different number of columns.
- See Also:
 
- 
augmentStacks matrices along rows.- Specified by:
- augmentin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- b- Matrix to stack to this matrix.
- Returns:
- The result of stacking bto the right of this matrix.
- Throws:
- IllegalArgumentException- If this matrix and matrix- bhave a different number of rows.
- See Also:
 
- 
augmentAugments a vector to this matrix.- Specified by:
- augmentin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- b- The vector to augment to this matrix.
- Returns:
- The result of augmenting bto this matrix.
 
- 
swapRowsSwaps specified rows in the matrix. This is done in place.- Specified by:
- swapRowsin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- rowIndex1- Index of the first row to swap.
- rowIndex2- Index of the second row to swap.
- Returns:
- A reference to this matrix.
- Throws:
- IndexOutOfBoundsException- If either index is outside the matrix bounds.
 
- 
swapColsSwaps specified columns in the matrix. This is done in place.- Specified by:
- swapColsin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- colIndex1- Index of the first column to swap.
- colIndex2- Index of the second column to swap.
- Returns:
- A reference to this matrix.
- Throws:
- ArrayIndexOutOfBoundsException- If either index is outside the matrix bounds.
 
- 
isSymmetricpublic boolean isSymmetric()Checks if a matrix is symmetric. That is, if the matrix is square and equal to its transpose.- Specified by:
- isSymmetricin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Returns:
- trueif this matrix is symmetric;- falseotherwise.
 
- 
isHermitianpublic boolean isHermitian()Checks if a matrix is Hermitian. That is, if the matrix is square and equal to its conjugate transpose.- Specified by:
- isHermitianin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Returns:
- trueif this matrix is Hermitian;- falseotherwise.
 
- 
isOrthogonalpublic boolean isOrthogonal()Checks if this matrix is orthogonal. That is, if the inverse of this matrix is approximately equal to its transpose.- Specified by:
- isOrthogonalin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Returns:
- trueif this matrix it is orthogonal;- falseotherwise.
 
- 
removeRowRemoves a specified row from this matrix.- Specified by:
- removeRowin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- rowIndex- Index of the row to remove from this matrix.
- Returns:
- A copy of this matrix with the specified row removed.
 
- 
removeRowsRemoves a specified set of rows from this matrix.- Specified by:
- removeRowsin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- rowIndices- The indices of the rows to remove from this matrix. Assumed to contain unique values.
- Returns:
- a copy of this matrix with the specified column removed.
 
- 
removeColRemoves a specified column from this matrix.- Specified by:
- removeColin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- colIndex- Index of the column to remove from this matrix.
- Returns:
- a copy of this matrix with the specified column removed.
 
- 
removeColsRemoves a specified set of columns from this matrix.- Specified by:
- removeColsin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- colIndices- Indices of the columns to remove from this matrix. Assumed to contain unique values.
- Returns:
- a copy of this matrix with the specified column removed.
 
- 
setSliceSets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set within this matrix.- Parameters:
- values- New values for the specified slice.
- rowStart- Starting row index for the slice (inclusive).
- colStart- Starting column index for the slice (inclusive).
- Returns:
- A reference to this matrix.
- Throws:
- IllegalArgumentException- If rowStart or colStart are not within the matrix.
- IllegalArgumentException- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
 
- 
setSliceCopyCreates a copy of this matrix and sets a slice of the copy to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
- setSliceCopyin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- values- New values for the specified slice.
- rowStart- Starting row index for the slice (inclusive).
- colStart- Starting column index for the slice (inclusive).
- Returns:
- A copy of this matrix with the given slice set to the specified values.
- Throws:
- IndexOutOfBoundsException- If rowStart or colStart are not within the matrix.
- IllegalArgumentException- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
 
- 
getSliceGets a specified slice of this matrix.- Specified by:
- getSlicein interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- rowStart- Starting row index of slice (inclusive).
- rowEnd- Ending row index of slice (exclusive).
- colStart- Starting column index of slice (inclusive).
- colEnd- Ending row index of slice (exclusive).
- Returns:
- The specified slice of this matrix. This is a completely new matrix and NOT a view into the matrix.
- Throws:
- ArrayIndexOutOfBoundsException- If any of the indices are out of bounds of this matrix.
- IllegalArgumentException- If- rowEndis not greater than- rowStartor if- colEndis not greater than- colStart.
 
- 
setSets an index of this matrix to the specified value.- Specified by:
- setin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- value- Value to set.
- row- Row index to set.
- col- Column index to set.
- Returns:
- A reference to this matrix.
 
- 
setValuesSets the value of this matrix using a 2D array.- Parameters:
- values- New values of the matrix.
- Returns:
- A reference to this matrix.
- Throws:
- IllegalArgumentException- If the values array has a different shape then this matrix.
 
- 
getTriUExtracts the upper-triangular portion of this matrix with a specified diagonal offset. All other data of the resulting matrix will be zero.- Specified by:
- getTriUin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- diagOffset- Diagonal offset for upper-triangular portion to extract:- If zero, then all data at and above the principle diagonal of this matrix are extracted.
- If positive, then all data at and above the equivalent super-diagonal are extracted.
- If negative, then all data at and above the equivalent sub-diagonal are extracted.
 
- Returns:
- The upper-triangular portion of this matrix with a specified diagonal offset. All other data of the returned matrix will be zero.
- Throws:
- IllegalArgumentException- If- diagOffsetis not in the range (-numRows, numCols).
 
- 
getTriLExtracts the lower-triangular portion of this matrix with a specified diagonal offset. All other data of the resulting matrix will be zero.- Specified by:
- getTriLin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- diagOffset- Diagonal offset for lower-triangular portion to extract:- If zero, then all data at and above the principle diagonal of this matrix are extracted.
- If positive, then all data at and above the equivalent super-diagonal are extracted.
- If negative, then all data at and above the equivalent sub-diagonal are extracted.
 
- Returns:
- The lower-triangular portion of this matrix with a specified diagonal offset. All other data of the returned matrix will be zero.
- Throws:
- IllegalArgumentException- If- diagOffsetis not in the range (-numRows, numCols).
 
- 
getDiagGets the elements of this matrix along the specified diagonal.- Specified by:
- getDiagin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- diagOffset- The diagonal to get within this matrix.- If diagOffset == 0: Then the elements of the principle diagonal are collected.
- If diagOffset < 0: Then the elements of the sub-diagonaldiagOffsetbelow the principle diagonal are collected.
- If diagOffset > 0: Then the elements of the super-diagonaldiagOffsetabove the principle diagonal are collected.
 
- If 
- Returns:
- The elements of the specified diagonal as a vector.
 
- 
setRowSets a specified row of this matrix to a vector.- Specified by:
- setRowin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- row- Vector to replace specified row in this matrix.
- rowIdx- Index of the row to set.
- Returns:
- If this matrix is dense, the row set operation is done in place and a reference to this matrix is returned. If this matrix is sparse a copy will be created with the new row and returned.
 
- 
setRowSets a specified row of this matrix to an array.- Parameters:
- row- Array containing values to replace specified row in this matrix.
- rowIdx- Index of the row to set.
- Returns:
- If this matrix is dense, the row set operation is done in place and a reference to this matrix is returned. If this matrix is sparse a copy will be created with the new row and returned.
 
- 
setColSets a specified column of this matrix to a vector.- Specified by:
- setColin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- col- Vector to replace specified column in this matrix.
- colIdx- Index of the column to set.
- Returns:
- If this matrix is dense, the column set operation is done in place and a reference to this matrix is returned. If this matrix is sparse a copy will be created with the new column and returned.
 
- 
setColSets a specified column of this matrix to an array.- Parameters:
- col- Vector to replace specified column in this matrix.
- colIdx- Index of the column to set.
- Returns:
- If this matrix is dense, the column set operation is done in place and a reference to this matrix is returned. If this matrix is sparse a copy will be created with the new column and returned.
 
- 
getRowGets a specified row of this matrix betweencolStart(inclusive) andcolEnd(exclusive).- Specified by:
- getRowin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- rowIdx- Index of the row of this matrix to get.
- colStart- Starting column of the row (inclusive).
- colEnd- Ending column of the row (exclusive).
- Returns:
- The row at index rowIdxof this matrix between thecolStartandcolEndindices.
- Throws:
- IndexOutOfBoundsException- If either- colEndare- colStartout of bounds for the shape of this matrix.
- IllegalArgumentException- If- colEndis less than- colStart.
 
- 
getColGets a specified column of this matrix betweenrowStart(inclusive) androwEnd(exclusive).- Specified by:
- getColin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Parameters:
- colIdx- Index of the column of this matrix to get.
- rowStart- Starting row of the column (inclusive).
- rowEnd- Ending row of the column (exclusive).
- Returns:
- The column at index colIdxof this matrix between therowStartandrowEndindices.
- Throws:
- IndexOutOfBoundsException- If either- colEndare- colStartout of bounds for the shape of this matrix.
- IllegalArgumentException- If- rowEndis less than- rowStart.
 
- 
flatten
- 
flattenFlattens this matrix along the specified axis.- Overrides:
- flattenin class- AbstractDenseSemiringTensor<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - V extends Semiring<V>> 
- Parameters:
- axis- Axis along which to flatten tensor.
- Returns:
- If axis == 0a matrix with the shape(1, this.numRows*this.numCols)is returned. Ifaxis == 1a matrix with the shape(this.numRows*this.numCols, 1)is returned.
- Throws:
- ArrayIndexOutOfBoundsException- If the axis is not positive or larger than- this.{@link #getRank()}-1.
- See Also:
 
- 
HComputes the Hermitian transpose of this matrix.- Specified by:
- Hin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Returns:
- The Hermitian transpose of this matrix.
 
- 
toCooConverts this matrix to an equivalent sparse COO matrix.- Overrides:
- toCooin class- AbstractDenseSemiringTensor<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - V extends Semiring<V>> 
- Returns:
- A sparse COO matrix that is equivalent to this dense matrix.
- See Also:
 
- 
toCooConverts this matrix to an equivalent sparse COO matrix.- Overrides:
- toCooin class- AbstractDenseSemiringTensor<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - V extends Semiring<V>> 
- Parameters:
- estimatedSparsity- Estimated sparsity of the matrix. Must be between 0 and 1 inclusive. If this is an accurate estimation it may provide a slight speedup and can reduce unneeded memory consumption. If memory is a concern, it is better to over-estimate the sparsity. If speed is the concern it is better to under-estimate the sparsity.
- Returns:
- A sparse COO matrix that is equivalent to this dense matrix.
- See Also:
 
- 
toCsrConverts this matrix to an equivalent sparse CSR matrix.- Returns:
- A sparse CSR matrix that is equivalent to this dense matrix.
- See Also:
 
- 
toCsrConverts this matrix to an equivalent sparse CSR matrix.- Parameters:
- estimatedSparsity- Estimated sparsity of the matrix. Must be between 0 and 1 inclusive. If this is an accurate estimation it may provide a slight speedup and can reduce unneeded memory consumption. If memory is a concern, it is better to over-estimate the sparsity. If speed is the concern it is better to under-estimate the sparsity.
- Returns:
- A sparse CSR matrix that is equivalent to this dense matrix.
- See Also:
 
- 
toVectorConverts this matrix to an equivalent vector. If this matrix is not a row or column vector it will first be flattened then converted to a vector.- Specified by:
- toVectorin interface- MatrixMixin<T extends AbstractDenseSemiringMatrix<T,- U, - V>, - T extends AbstractDenseSemiringMatrix<T, - U, - V>, - U extends AbstractDenseSemiringVector<U, - T, - V>, - V extends Semiring<V>> 
- Returns:
- A vector which contains the same data as this matrix.
 
- 
toTensorConverts this matrix to an equivalent tensor.- Returns:
- A tensor with the same shape and data as this matrix.
 
- 
toTensorConverts this matrix to an equivalent tensor with the specifiednewShape.- Parameters:
- newShape- Shape of the tensor. Can be any rank but must be broadcastable to the shape of this matrix.
- Returns:
- A tensor with the specified newShapeand the same data as this matrix.
 
 
-