com.tagtraum.jipes.math

## Interface Matrix

• ### Method Summary

All Methods
Modifier and Type Method and Description
`Matrix` `add(Matrix m)`
Creates a view that is equal to the result of an addition.
`float[]` `columnSum()`
Compute the sum for each column.
`Matrix` `enlarge(Matrix m)`
Creates a view that is as large as the larger of the two involved matrices.
`float` ```get(int row, int column)```
Gets the value from `row` and `column`.
`float[]` `getColumn(int column)`
Gets the value from `column`.
`int` `getNumberOfColumns()`
Number of columns.
`int` `getNumberOfRows()`
Number of rows
`float[]` `getRow(int row)`
Gets the values from `row`.
`Matrix` `hadamardMultiply(Matrix m)`
Creates a view that is equal to the result of a Hadamard multiplication.
`boolean` `isZeroPadded()`
Indicates whether this matrix is zero padded.
`Matrix` `multiply(float f)`
Creates a view that is equal to the result of a scalar multiplication.
`Matrix` `multiply(Matrix m)`
Creates a view that is equal to the result of a matrix multiplication.
`float[]` `rowSum()`
Compute the sum for each row.
`Matrix` `subtract(Matrix m)`
Creates a view that is equal to the result of an subtraction.
`float` `sum()`
Compute the sum of all elements.
`Matrix` ```translate(int rows, int columns)```
Creates a view that is equal to the result of a matrix translation.
`Matrix` `transpose()`
Creates a view that is equal to the result of a matrix transposition.
• ### Method Detail

• #### get

```float get(int row,
int column)```
Gets the value from `row` and `column`. If the matrix supports zero-padding, this method may return `0f` for undefined rows or columns.
Parameters:
`row` - row
`column` - column
Returns:
value
Throws:
`IndexOutOfBoundsException` - if row, column or both are out of bounds and the matrix does not support zero padding
• #### sum

`float sum()`
Compute the sum of all elements.
Returns:
sum
• #### rowSum

`float[] rowSum()`
Compute the sum for each row.
Returns:
sum for all rows
• #### columnSum

`float[] columnSum()`
Compute the sum for each column.
Returns:
sum for all columns
• #### getRow

`float[] getRow(int row)`
Gets the values from `row`. If the matrix supports zero-padding, this method may return `0f` for undefined rows or columns.
Parameters:
`row` - row
Returns:
value
Throws:
`IndexOutOfBoundsException` - if the row is out of bounds and the matrix does not support zero padding
• #### getColumn

`float[] getColumn(int column)`
Gets the value from `column`. If the matrix supports zero-padding, this method may return `0f` for undefined columns.
Parameters:
`column` - column
Returns:
value
Throws:
`IndexOutOfBoundsException` - if the column is out of bounds and the matrix does not support zero padding
• #### getNumberOfRows

`int getNumberOfRows()`
Number of rows
Returns:
rows
• #### getNumberOfColumns

`int getNumberOfColumns()`
Number of columns.
Returns:
columns

`boolean isZeroPadded()`
Returns:
true or false

`Matrix add(Matrix m)`
Creates a view that is equal to the result of an addition.
Parameters:
`m` - matrix to add to this
Returns:
• #### subtract

`Matrix subtract(Matrix m)`
Creates a view that is equal to the result of an subtraction.
Parameters:
`m` - matrix to subtract from this
Returns:
subtract view
• #### multiply

`Matrix multiply(float f)`
Creates a view that is equal to the result of a scalar multiplication.
Parameters:
`f` - scalar
Returns:
multiplication view
• #### multiply

`Matrix multiply(Matrix m)`
Creates a view that is equal to the result of a matrix multiplication.
Parameters:
`m` - matrix to multiply this with
Returns:
multiplication view

`Matrix hadamardMultiply(Matrix m)`
Creates a view that is equal to the result of a Hadamard multiplication.
Parameters:
`m` - matrix to multiply this with
Returns:
multiplication view
• #### transpose

`Matrix transpose()`
Creates a view that is equal to the result of a matrix transposition.
Returns:
transposition view
• #### enlarge

`Matrix enlarge(Matrix m)`
Creates a view that is as large as the larger of the two involved matrices. Values are equal to the values of this matrix, as long as its maximal indices aren't exceeded. Once they are exceeded, the given matrix is used as "backup". If its indices are also exceeded its padding (if available) is returned upon read operations.
In essence this operation adds the given matrix to this matrix for those rows and columns where this matrix isn't defined. The existing values of the given matrix are invisible for those indices where this matrix is defined.
Parameters:
`m` - matrix
Returns:
enlarged matrix combining this and the given matrix
• #### translate

```Matrix translate(int rows,
int columns)```
Creates a view that is equal to the result of a matrix translation. I.e. the content of the matrix is moved to a different position in a larger matrix.
Parameters:
`rows` - number of rows to move the matrix
`columns` - number of columns to move the matrix
Returns:
transposition view