# DefaultIntMatrix

`class DefaultIntMatrix :``Matrix``<``Int``>`

### Constructors

Name Summary
<init> `DefaultIntMatrix(rows:``Int``, cols:``Int``)`

### Properties

Name Summary
cols `val cols:``Int`
rows `val rows:``Int`
storage `val storage:``IntArray`

### Inherited Properties

Name Summary
T `open val T:``Matrix``<``T``>`
Transpose operator.
size `open val size:``Int`

### Functions

Name Summary
LU `fun LU():``Triple``<``Matrix``<``Int``>,``Matrix``<``Int``>,``Matrix``<``Int``>>`
LU Decomposition. Returns p, l, u matrices as a triple.
QR `fun QR():``Pair``<``Matrix``<``Int``>,``Matrix``<``Int``>>`
SVD `fun SVD():``Triple``<``Matrix``<``Int``>,``Matrix``<``Int``>,``Matrix``<``Int``>>`
T `fun T():``Matrix``<``Int``>`
Transpose operator.
argMax `fun argMax():``Int`
Row major 1D index.
argMin `fun argMin():``Int`
Row major 1D index.
chol `fun chol():``Matrix``<``Int``>`
(lower triangular) Cholesky decomposition of the matrix. Matrix must be positive-semi definite.
copy `fun copy():``Matrix``<``Int``>`
Returns a copy of this matrix (same values, new memory)
det `fun det():``Int`
Determinant of the matrix
diag `fun diag():``Matrix``<``Int``>`
div `fun div(other:``Int``):``Matrix``<``Int``>`
elementSum `fun elementSum():``Int`
Sum of all the elements in the matrix.
elementTimes `fun elementTimes(other:``Matrix``<``Int``>):``Matrix``<``Int``>`
Element-wise multiplication with another matrix
epow `fun epow(other:``Int``):``Matrix``<``Int``>`
Element-wise exponentiation of each element in the matrix
expm `fun expm():``Matrix``<``Int``>`
Compute the matrix exponential e^x (NOT elementwise)
getBaseMatrix `fun getBaseMatrix():``Any`
Returns the underlying matrix object from the back-end this Matrix is wrapping. This should be used sparingly (as it breaks encapsulation), but it can increase performance by using computation specifically designed for a particular back-end. Code using this method should not rely on a particular back-end, and should always fallback to slow generic code if an unrecognized matrix is returned here (e.g. use get and set) to access the elements generically).
getCol `fun getCol(col:``Int``):``Matrix``<``Int``>`
getDouble `fun getDouble(i:``Int``, j:``Int``):``Double`
`fun getDouble(i:``Int``):``Double`
getDoubleData `fun getDoubleData():``DoubleArray`
Retrieves the data formatted as doubles in row-major order This method is only for performance over potentially boxing get(Double) methods. This method may or may not return a copy, and thus should be treated as read-only unless backend behavior is known.
getFactory `fun getFactory():``MatrixFactory``<``Matrix``<``Int``>>`
Because sometimes all you have is a Matrix, but you really want a MatrixFactory.
getFloat `fun getFloat(i:``Int``, j:``Int``):``Float`
`fun getFloat(i:``Int``):``Float`
getGeneric `fun getGeneric(i:``Int``, j:``Int``):``Int`
`fun getGeneric(i:``Int``):``Int`
getInt `fun getInt(i:``Int``, j:``Int``):``Int`
`fun getInt(i:``Int``):``Int`
getRow `fun getRow(row:``Int``):``Matrix``<``Int``>`
inv `fun inv():``Matrix``<``Int``>`
Matrix inverse (square matrices)
max `fun max():``Int`
Maximum value contained in the matrix
mean `fun mean():``Int`
Mean (average) of all the elements in the matrix.
min `fun min():``Int`
Minimum value contained in the matrix
minus `fun minus(other:``Int``):``Matrix``<``Int``>`
`fun minus(other:``Matrix``<``Int``>):``Matrix``<``Int``>`
normF `fun normF():``Int`
Frobenius normal of the matrix
normIndP1 `fun normIndP1():``Int`
Induced, p=1 normal of the matrix. Equivalent of `norm(matrix,1)` in scipy.
numCols `fun numCols():``Int`
Number of columns in the matrix
numRows `fun numRows():``Int`
Number of rows in the matrix
pinv `fun pinv():``Matrix``<``Int``>`
Pseudo-inverse of (non-square) matrix
plus `fun plus(other:``Int``):``Matrix``<``Int``>`
`fun plus(other:``Matrix``<``Int``>):``Matrix``<``Int``>`
setCol `fun setCol(index:``Int``, col:``Matrix``<``Int``>):``Unit`
setDouble `fun setDouble(i:``Int``, v:``Double``):``Unit`
`fun setDouble(i:``Int``, j:``Int``, v:``Double``):``Unit`
setFloat `fun setFloat(i:``Int``, v:``Float``):``Unit`
`fun setFloat(i:``Int``, j:``Int``, v:``Float``):``Unit`
setGeneric `fun setGeneric(i:``Int``, v:``Int``):``Unit`
`fun setGeneric(i:``Int``, j:``Int``, v:``Int``):``Unit`
setInt `fun setInt(i:``Int``, v:``Int``):``Unit`
`fun setInt(i:``Int``, j:``Int``, v:``Int``):``Unit`
setRow `fun setRow(index:``Int``, row:``Matrix``<``Int``>):``Unit`
solve `fun solve(other:``Matrix``<``Int``>):``Matrix``<``Int``>`
Solves A*X=B for X, returning X (X is either column vector or a matrix composed of several col vectors). A is the current matrix, B is the passed in other)/other), and X is the returned matrix.
times `fun times(other:``Matrix``<``Int``>):``Matrix``<``Int``>`
`fun times(other:``Int``):``Matrix``<``Int``>`
trace `fun trace():``Int`
The matrix trace.
transpose `fun transpose():``Matrix``<``Int``>`
Transpose of the matrix
unaryMinus `fun unaryMinus():``Matrix``<``Int``>`

### Inherited Functions

Name Summary
asColVector `open fun asColVector():``Matrix``<``T``>`
Returns the given vector as a row vector. Will call transpose() on row vectors
asRowVector `open fun asRowVector():``Matrix``<``T``>`
Returns the given vector as a row vector. Will call transpose() on column vectors
cumSum `open fun cumSum():``Matrix``<``T``>`
Calculates the cumulative (ongoing) sum of a matrix's elements. For example, `cumsum(mat[1,2,3])` would return `mat[1,3,6]`. Assumes matrix type is convertible to double.
filterCols `open fun filterCols(f: (col:``Matrix``<``T``>) ->``Boolean``):``Matrix``<``T``>`
Builds a new matrix with a subset of the columns of this matrix, using only the columns for which the function f returns true.
filterColsIndexed `open fun filterColsIndexed(f: (colIndex:``Int``, col:``Matrix``<``T``>) ->``Boolean``):``Matrix``<``T``>`
Builds a new matrix with a subset of the columns of this matrix, using only the columns for which the function f returns true.
filterRows `open fun filterRows(f: (row:``Matrix``<``T``>) ->``Boolean``):``Matrix``<``T``>`
Builds a new matrix with a subset of the rows of this matrix, using only the rows for which the function f returns true.
filterRowsIndexed `open fun filterRowsIndexed(f: (rowIndex:``Int``, row:``Matrix``<``T``>) ->``Boolean``):``Matrix``<``T``>`
Builds a new matrix with a subset of the rows of this matrix, using only the rows for which the function f returns true.
forEachCol `open fun forEachCol(f: (``Matrix``<``T``>) ->``Unit``):``Unit`
Passes each col from left to right into a function.
forEachRow `open fun forEachRow(f: (``Matrix``<``T``>) ->``Unit``):``Unit`
Passes each row from top to bottom into a function.
getBaseArray `open fun getBaseArray():``Any`
getByte `open fun getByte(vararg indices:``Int``):``Byte`
getDouble `open fun getDouble(vararg indices:``Int``):``Double`
getFloat `open fun getFloat(vararg indices:``Int``):``Float`
getGeneric `open fun getGeneric(vararg indices:``Int``):``T`
getInt `open fun getInt(vararg indices:``Int``):``Int`
getLinear `open fun getLinear(index:``Int``):``T`
getLong `open fun getLong(vararg indices:``Int``):``Long`
getShort `open fun getShort(vararg indices:``Int``):``Short`
mapCols `open fun mapCols(f: (``Matrix``<``T``>) ->``Matrix``<``T``>):``Matrix``<``T``>`
Takes each col in a matrix, passes them through f, and puts the output of f into a col of an output matrix.
mapColsToList `open fun <U> mapColsToList(f: (``Matrix``<``T``>) ->``U``):``List``<``U``>`
Takes each col in a matrix, passes them through f, and puts the outputs into a List. In contrast to this#mapCols, the usage of a list as the output container allows for arbitrary output types, such as taking a double matrix and returning a list of strings.
mapRows `open fun mapRows(f: (``Matrix``<``T``>) ->``Matrix``<``T``>):``Matrix``<``T``>`
Takes each row in a matrix, passes them through f, and puts the output of f into a row of an output matrix.
mapRowsToList `open fun <U> mapRowsToList(f: (``Matrix``<``T``>) ->``U``):``List``<``U``>`
Takes each row in a matrix, passes them through f, and puts the outputs into a List. In contrast to this#mapRows, the usage of a list as the output container allows for arbitrary output types, such as taking a double matrix and returning a list of strings.
pow `open infix fun pow(exponent:``Int``):``Matrix``<``T``>`
Multiplies the matrix by itself exponent times (using matrix multiplication).
repr `open fun repr():``String`
selectCols `open fun selectCols(vararg idxs:``Int``):``Matrix``<``T``>`
Select a set of cols from a matrix to form the cols of a new matrix. For example, if you wanted a new matrix consisting of the first, second, and fifth cols of an input matrix, you would write `input.selectCols(0,1,4)`.`open fun <U :``Number``> selectCols(idxs:``Matrix``<``U``>):``Matrix``<``T``>`
selectRows `open fun selectRows(vararg idxs:``Int``):``Matrix``<``T``>`
Select a set of rows from a matrix to form the rows of a new matrix. For example, if you wanted a new matrix consisting of the first, second, and fifth rows of an input matrix, you would write `input.selectRows(0,1,4)`.`open fun <U :``Number``> selectRows(idxs:``Matrix``<``U``>):``Matrix``<``T``>`
setByte `open fun setByte(vararg indices:``Int``, value:``Byte``):``Nothing`
setDouble `open fun setDouble(vararg indices:``Int``, value:``Double``):``Unit`
setFloat `open fun setFloat(vararg indices:``Int``, value:``Float``):``Unit`
setGeneric `open fun setGeneric(vararg indices:``Int``, value:``T``):``Unit`
setInt `open fun setInt(vararg indices:``Int``, value:``Int``):``Unit`
setLinear `open fun setLinear(index:``Int``, value:``T``):``Unit`
setLong `open fun setLong(vararg indices:``Int``, value:``Long``):``Nothing`
setShort `open fun setShort(vararg indices:``Int``, value:``Short``):``Nothing`
shape `open fun shape():``List``<``Int``>`
to2DArray `open fun to2DArray():``Array``<``DoubleArray``>`
Returns a Matrix as a double 2D array. Intended for MATLAB interop.
toIterable `open fun toIterable():``Iterable``<``T``>`
wrapRange `open fun wrapRange(range:``IntRange``, max:``Int``):``IntRange`

### Extension Functions

Name Summary
all `fun <T>``Matrix``<``T``>.all(f: (``T``) ->``Boolean``):``Boolean`
`fun``Matrix``<``Int``>.all(f: (``Int``) ->``Boolean``):``Boolean`
Checks to see if all elements cause f to return true.
any `fun <T>``Matrix``<``T``>.any(f: (``T``) ->``Boolean``):``Boolean`
`fun``Matrix``<``Int``>.any(f: (``Int``) ->``Boolean``):``Boolean`
Checks to see if any element in the matrix causes f to return true.
checkIndices `fun <T>``NDArray``<``T``>.checkIndices(indices:``IntArray``):``IntArray`
checkLinearIndex `fun <T>``NDArray``<``T``>.checkLinearIndex(index:``Int``):``Int`
div `operator fun``NDArray``<``Int``>.div(other:``Int``):``NDArray``<``Int``>`
fill `fun <T>``Matrix``<``T``>.fill(f: (row:``Int``, col:``Int``) ->``T``):``Matrix``<``T``>`
`fun``Matrix``<``Int``>.fill(f: (row:``Int``, col:``Int``) ->``Int``):``Matrix``<``Int``>`
Fills the matrix with the values returned by the input function.`fun <T>``NDArray``<``T``>.fill(f: (idx:``IntArray``) ->``T``):``NDArray``<``T``>`
`fun``NDArray``<``Int``>.fill(f: (idx:``IntArray``) ->``Int``):``NDArray``<``Int``>`
fillBoth `fun <T>``NDArray``<``T``>.fillBoth(f: (nd:``IntArray``, linear:``Int``) ->``T``):``NDArray``<``T``>`
`fun``NDArray``<``Int``>.fillBoth(f: (nd:``IntArray``, linear:``Int``) ->``Int``):``NDArray``<``Int``>`
fillLinear `fun <T>``NDArray``<``T``>.fillLinear(f: (idx:``Int``) ->``T``):``NDArray``<``T``>`
`fun``NDArray``<``Int``>.fillLinear(f: (idx:``Int``) ->``Int``):``NDArray``<``Int``>`
forEach `fun <T>``Matrix``<``T``>.forEach(f: (``T``) ->``Unit``):``Unit`
Passes each element in row major order into a function.`fun <T>``NDArray``<``T``>.forEach(f: (ele:``T``) ->``Unit``):``Unit`
Takes each element in a NDArray and passes them through f.
forEachIndexed `fun <T>``Matrix``<``T``>.forEachIndexed(f: (row:``Int``, col:``Int``, ele:``T``) ->``Unit``):``Unit`
`fun``Matrix``<``Int``>.forEachIndexed(f: (row:``Int``, col:``Int``, ele:``Int``) ->``Unit``):``Unit`
Passes each element in row major order into a function along with its index location.`fun <T>``NDArray``<``T``>.forEachIndexed(f: (idx:``Int``, ele:``T``) ->``Unit``):``Unit`
`fun``NDArray``<``Int``>.forEachIndexed(f: (idx:``Int``, ele:``Int``) ->``Unit``):``Unit`
Takes each element in a NDArray and passes them through f. Index given to f is a linear index, depending on the underlying storage major dimension.
forEachIndexedN `fun <T>``NDArray``<``T``>.forEachIndexedN(f: (idx:``IntArray``, ele:``T``) ->``Unit``):``Unit`
`fun``NDArray``<``Int``>.forEachIndexedN(f: (idx:``IntArray``, ele:``Int``) ->``Unit``):``Unit`
Takes each element in a NDArray and passes them through f. Index given to f is the full ND index of the element.
linearToNIdx `fun <T>``NDArray``<``T``>.linearToNIdx(linear:``Int``):``IntArray`
Given the 1D index of an element in the underlying storage, find the corresponding ND index. Inverse of nIdxToLinear.
map `fun <T>``Matrix``<``T``>.map(f: (``T``) ->``T``):``Matrix``<``T``>`
Takes each element in a matrix, passes them through f, and puts the output of f into an output matrix. This process is done in row-major order.`fun <T>``NDArray``<``T``>.map(f: (``T``) ->``T``):``DefaultGenericNDArray``<``T``>`
Takes each element in a NDArray, passes them through f, and puts the output of f into an output NDArray.
mapIndexed `fun <T>``Matrix``<``T``>.mapIndexed(f: (row:``Int``, col:``Int``, ele:``T``) ->``T``):``Matrix``<``T``>`
`fun``Matrix``<``Int``>.mapIndexed(f: (row:``Int``, col:``Int``, ele:``Int``) ->``Int``):``Matrix``<``Int``>`
Takes each element in a matrix, passes them through f, and puts the output of f into an output matrix. This process is done in row-major order.`fun <T>``NDArray``<``T``>.mapIndexed(f: (idx:``Int``, ele:``T``) ->``T``):``DefaultGenericNDArray``<``T``>`
`fun``NDArray``<``Int``>.mapIndexed(f: (idx:``Int``, ele:``Int``) ->``Int``):``NDArray``<``Int``>`
Takes each element in a NDArray, passes them through f, and puts the output of f into an output NDArray. Index given to f is a linear index, depending on the underlying storage major dimension.
mapIndexedN `fun <T>``NDArray``<``T``>.mapIndexedN(f: (idx:``IntArray``, ele:``T``) ->``T``):``NDArray``<``T``>`
`fun``NDArray``<``Int``>.mapIndexedN(f: (idx:``IntArray``, ele:``Int``) ->``Int``):``NDArray``<``Int``>`
Takes each element in a NDArray, passes them through f, and puts the output of f into an output NDArray. Index given to f is the full ND index of the element.
minus `operator fun``NDArray``<``Int``>.minus(other:``Int``):``NDArray``<``Int``>`
`operator fun``NDArray``<``Int``>.minus(other:``NDArray``<``Int``>):``NDArray``<``Int``>`
nIdxToLinear `fun <T>``NDArray``<``T``>.nIdxToLinear(indices:``IntArray``):``Int`
Given a ND index into this array, find the corresponding 1D index in the raw underlying 1D storage array.
plus `operator fun``NDArray``<``Int``>.plus(other:``Int``):``NDArray``<``Int``>`
`operator fun``NDArray``<``Int``>.plus(other:``NDArray``<``Int``>):``NDArray``<``Int``>`
pow `infix fun``NDArray``<``Int``>.pow(exponent:``Int``):``NDArray``<``Int``>`
safeNIdxToLinear `fun <T>``NDArray``<``T``>.safeNIdxToLinear(indices:``IntArray``):``Int`
set `operator fun <T>``Matrix``<``T``>.set(i:``Int``, v:``T``):``Unit`
`operator fun``Matrix``<``Int``>.set(i:``Int``, v:``Int``):``Unit`
Set the ith element in the matrix. If 2D, selects elements in row-major order.`operator fun <T>``Matrix``<``T``>.set(i:``Int``, j:``Int``, v:``T``):``Unit`
`operator fun <T>``Matrix``<``T``>.set(rows:``IntRange``, cols:``IntRange``, value:``T``):``Unit`
`operator fun <T>``Matrix``<``T``>.set(rows:``Int``, cols:``IntRange``, value:``T``):``Unit`
`operator fun <T>``Matrix``<``T``>.set(rows:``IntRange``, cols:``Int``, value:``T``):``Unit`
`operator fun``Matrix``<``Int``>.set(i:``Int``, j:``Int``, v:``Int``):``Unit`
`operator fun``Matrix``<``Int``>.set(rows:``IntRange``, cols:``IntRange``, value:``Int``):``Unit`
`operator fun``Matrix``<``Int``>.set(rows:``Int``, cols:``IntRange``, value:``Int``):``Unit`
`operator fun``Matrix``<``Int``>.set(rows:``IntRange``, cols:``Int``, value:``Int``):``Unit`
`operator fun <T>``NDArray``<``T``>.set(vararg indices:``Int``, value:``NDArray``<``T``>):``Unit`
`operator fun <T>``NDArray``<``T``>.set(vararg indices:``Int``, value:``T``):``Unit`
`operator fun``NDArray``<``Int``>.set(vararg indices:``Int``, value:``NDArray``<``Int``>):``Unit`
`operator fun``NDArray``<``Int``>.set(vararg indices:``Int``, value:``Int``):``Unit``operator fun <T>``Matrix``<``T``>.set(rows:``IntRange``, cols:``IntRange``, value:``Matrix``<``T``>):``Unit`
`operator fun``Matrix``<``Int``>.set(rows:``IntRange``, cols:``IntRange``, value:``Matrix``<``Int``>):``Unit`
Allow assignment to a slice, e.g. `matrix[1..2, 3..4]`=something. Note that the range 1..2 is inclusive, so it will retrieve row 1 and 2. Use 1.until(2) for a non-inclusive range.`operator fun <T>``Matrix``<``T``>.set(rows:``Int``, cols:``IntRange``, value:``Matrix``<``T``>):``Unit`
`operator fun``Matrix``<``Int``>.set(rows:``Int``, cols:``IntRange``, value:``Matrix``<``Int``>):``Unit`
Allow assignment to a slice, e.g. `matrix[2, 3..4]`=something. Note that the range 3..4 is inclusive, so it will retrieve col 3 and 4. Use 1.until(2) for a non-inclusive range.`operator fun <T>``Matrix``<``T``>.set(rows:``IntRange``, cols:``Int``, value:``Matrix``<``T``>):``Unit`
`operator fun``Matrix``<``Int``>.set(rows:``IntRange``, cols:``Int``, value:``Matrix``<``Int``>):``Unit`
Allow assignment to a slice, e.g. `matrix[1..2, 3]`=something. Note that the range 1..2 is inclusive, so it will retrieve row 1 and 2. Use 1.until(2) for a non-inclusive range.
times `operator fun``NDArray``<``Int``>.times(other:``NDArray``<``Int``>):``NDArray``<``Int``>`
`operator fun``NDArray``<``Int``>.times(other:``Int``):``NDArray``<``Int``>`
toIntArray `fun``NDArray``<``Int``>.toIntArray():``IntArray`
Converts this NDArray into a one-dimensional IntArray in row-major order.
toMatrix `fun``NDArray``<``Int``>.toMatrix():``Matrix``<``Int``>`
toMatrixOrNull `fun <T>``NDArray``<``T``>.toMatrixOrNull():``Matrix``<``T``>?`
toTypedArray `fun <T>``NDArray``<``T``>.toTypedArray():``Array``<``T``>`
Converts this NDArray into a one-dimensional Array in row-major order.
unaryMinus `operator fun``NDArray``<``Int``>.unaryMinus():``NDArray``<``Int``>`
widthOfDims `fun <T>``NDArray``<``T``>.widthOfDims():``ArrayList``<``Int``>`