org.tribuo.math.la

Interface Matrix

• Method Detail

• get

double get(int i,
int j)
Gets an element from this Matrix.
Parameters:
i - The index for the first dimension.
j - The index for the second dimension.
Returns:
The value at matrix[i][j].
• set

void set(int i,
int j,
double value)
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].

int j,
double value)
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

int getDimension1Size()
The size of the first dimension.
Returns:
The size of the first dimension.
• getDimension2Size

int getDimension2Size()
The size of the second dimension.
Returns:
The size of the second dimension.
• numActiveElements

int numActiveElements(int row)
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.
• matrixMultiply

Matrix matrixMultiply(Matrix input)
Multiplies this Matrix by another Matrix returning a matrix of the appropriate size.

The input must have dimension 1 equal to getDimension2Size().

Parameters:
input - The input matrix.
Returns:
A new Matrix of size getDimension1Size(), input.getDimension2Size().
• matrixMultiply

Matrix matrixMultiply(Matrix input,
boolean transposeThis,
boolean transposeOther)
Multiplies this Matrix by another Matrix returning 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.
• getRow

SGDVector getRow(int i)
Extract a row as an SGDVector.

This refers to the same values as the matrix, so updating this vector will update the matrix.

Parameters:
i - The index of the row to extract.
Returns:
An SGDVector.