Interface Matrix
- All Superinterfaces:
Iterable<MatrixTuple>,Serializable,Tensor
- All Known Implementing Classes:
DenseMatrix,DenseSparseMatrix,ShrinkingMatrix
Interface for 2 dimensional
Tensors.
Matrices have immutable sizes and immutable indices (so DenseSparseMatrix can't grow).
-
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int i, int j, double value) Adds the argument value to the value at the supplied index.doubleget(int i, int j) Gets an element from thisMatrix.intThe size of the first dimension.intThe size of the second dimension.getRow(int i) Extract a row as anSGDVector.leftMultiply(SGDVector input) Multiplies this Matrix by aSGDVectorreturning a vector of the appropriate size.matrixMultiply(Matrix input) Multiplies this Matrix by anotherMatrixreturning a matrix of the appropriate size.matrixMultiply(Matrix input, boolean transposeThis, boolean transposeOther) Multiplies this Matrix by anotherMatrixreturning a matrix of the appropriate size.intnumActiveElements(int row) The number of non-zero elements in that row.rightMultiply(SGDVector input) Multiplies this Matrix by aSGDVectorreturning a vector of the appropriate size.voidrowScaleInPlace(DenseVector scalingCoefficients) Scales each row by the appropriate value in theDenseVector.rowSum()Generates aDenseVectorrepresenting the sum of each row.voidset(int i, int j, double value) Sets an element at the supplied location.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface org.tribuo.math.la.Tensor
foreachInPlace, getShape, hadamardProductInPlace, hadamardProductInPlace, intersectAndAddInPlace, intersectAndAddInPlace, reshape, scalarAddInPlace, scaleInPlace, twoNorm
-
Method Details
-
get
-
set
Sets an element at the supplied location.- Parameters:
i- The index for the first dimension.j- The index for the second dimension.value- The value to be stored at matrix[i][j].
-
add
Adds the argument value to the value at the supplied index.- Parameters:
i- The index for the first dimension.j- The index for the second dimension.value- The value to add.
-
getDimension1Size
-
getDimension2Size
int getDimension2Size()The size of the second dimension.- Returns:
- The size of the second dimension.
-
numActiveElements
The number of non-zero elements in that row.An element could be active and zero, if it was active on construction.
- Parameters:
row- The index of the row.- Returns:
- The number of non-zero elements.
-
leftMultiply
Multiplies this Matrix by aSGDVectorreturning a vector of the appropriate size.The input must have dimension equal to
getDimension2Size().- Parameters:
input- The input vector.- Returns:
- A new
SGDVectorof sizegetDimension1Size().
-
rightMultiply
Multiplies this Matrix by aSGDVectorreturning a vector of the appropriate size.The input must have dimension equal to
getDimension1Size().- Parameters:
input- The input vector.- Returns:
- A new
SGDVectorof sizegetDimension2Size().
-
matrixMultiply
Multiplies this Matrix by anotherMatrixreturning a matrix of the appropriate size.The input must have dimension 1 equal to
getDimension2Size().- Parameters:
input- The input matrix.- Returns:
- A new
Matrixof sizegetDimension1Size(),input.getDimension2Size().
-
matrixMultiply
Multiplies this Matrix by anotherMatrixreturning a matrix of the appropriate size.Must obey the rules of matrix multiplication after the transposes are applied.
- Parameters:
input- The input matrix.transposeThis- Implicitly transposes this matrix just for the multiplication.transposeOther- Implicitly transposes other just for the multiplication.- Returns:
- A new
Matrix.
-
rowSum
Generates aDenseVectorrepresenting the sum of each row.- Returns:
- A new
DenseVectorof sizegetDimension1Size().
-
rowScaleInPlace
Scales each row by the appropriate value in theDenseVector.- Parameters:
scalingCoefficients- ADenseVectorwith sizegetDimension1Size().
-
getRow
-