api / koma.matrix.common / DoubleMatrixBase

DoubleMatrixBase

abstract class DoubleMatrixBase :MatrixBase<Double>

Some functionality to help more easily implement double based koma backends. Feel free to not use if your backend has fast implementations of these functions.

Constructors

Name Summary
<init> DoubleMatrixBase()
Some functionality to help more easily implement double based koma backends. Feel free to not use if your backend has fast implementations of these functions.

Functions

Name Summary
argMax open fun argMax():Int
Row major 1D index.
argMin open fun argMin():Int
Row major 1D index.
copy open fun copy():Matrix<Double>
Returns a copy of this matrix (same values, new memory)
div open fun div(other:Int):Matrix<Double>
open fun div(other:Double):Matrix<Double>
elementSum open fun elementSum():Double
Sum of all the elements in the matrix.
elementTimes open fun elementTimes(other:Matrix<Double>):Matrix<Double>
Element-wise multiplication with another matrix
epow open fun epow(other:Double):Matrix<Double>
Element-wise exponentiation of each element in the matrixopen fun epow(other:Int):Matrix<Double>
expm open fun expm():Matrix<Double>
Compute the matrix exponential e^x (NOT elementwise)
getCol open fun getCol(col:Int):Matrix<Double>
getFloat open fun getFloat(i:Int, j:Int):Float
open fun getFloat(i:Int):Float
getGeneric open fun getGeneric(i:Int):Double
open fun getGeneric(i:Int, j:Int):Double
getInt open fun getInt(i:Int, j:Int):Int
open fun getInt(i:Int):Int
getRow open fun getRow(row:Int):Matrix<Double>
max open fun max():Double
Maximum value contained in the matrix
mean open fun mean():Double
Mean (average) of all the elements in the matrix.
min open fun min():Double
Minimum value contained in the matrix
minus open fun minus(other:Double):Matrix<Double>
open fun minus(other:Matrix<Double>):Matrix<Double>
plus open fun plus(other:Matrix<Double>):Matrix<Double>
open fun plus(other:Double):Matrix<Double>
setCol open fun setCol(index:Int, col:Matrix<Double>):Unit
setFloat open fun setFloat(i:Int, v:Float):Unit
open fun setFloat(i:Int, j:Int, v:Float):Unit
setGeneric open fun setGeneric(i:Int, v:Double):Unit
open fun setGeneric(i:Int, j:Int, v:Double):Unit
setInt open fun setInt(i:Int, v:Int):Unit
open fun setInt(i:Int, j:Int, v:Int):Unit
setRow open fun setRow(index:Int, row:Matrix<Double>):Unit
times open fun times(other:Double):Matrix<Double>
transpose open fun transpose():Matrix<Double>
Transpose of the matrix
unaryMinus open fun unaryMinus():Matrix<Double>

Inherited Functions

Name Summary
castOrCopy fun <DType, TOuter :Matrix<DType>, TInner> castOrCopy(mat:Matrix<DType>, makeOuter: (TInner) ->TOuter, outerFac:MatrixFactory<TOuter>):TOuter
Attempts to downcast a matrix to its specific subclass, accepting both inner wrapped types and outer types. Requires the TOuter constructor to be passed in because reified generics don't support ctor calls. If the passed mat cannot be cast, instead copies the data manually into a newly allocated matrix of the correct type.
equals open fun equals(other:Any?):Boolean
hashCode open fun hashCode():Int
toString open fun toString():String

Extension Functions

Name Summary
all funMatrix<Double>.all(f: (Double) ->Boolean):Boolean
fun <T>Matrix<T>.all(f: (T) ->Boolean):Boolean
Checks to see if all elements cause f to return true.
allClose funMatrix<Double>.allClose(other:Matrix<Double>, rtol:Double= 1e-05, atol:Double= 1e-08):Boolean
any funMatrix<Double>.any(f: (Double) ->Boolean):Boolean
fun <T>Matrix<T>.any(f: (T) ->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 funNDArray<Double>.div(other:Double):NDArray<Double>
emul infix funMatrix<Double>.emul(other:Matrix<Double>):Matrix<Double>
Allow infix operator "a emul b" to be element-wise multiplication of two matrices.
fill funMatrix<Double>.fill(f: (row:Int, col:Int) ->Double):Matrix<Double>
fun <T>Matrix<T>.fill(f: (row:Int, col:Int) ->T):Matrix<T>
Fills the matrix with the values returned by the input function.funNDArray<Double>.fill(f: (idx:IntArray) ->Double):NDArray<Double>
fun <T>NDArray<T>.fill(f: (idx:IntArray) ->T):NDArray<T>
fillBoth funNDArray<Double>.fillBoth(f: (nd:IntArray, linear:Int) ->Double):NDArray<Double>
fun <T>NDArray<T>.fillBoth(f: (nd:IntArray, linear:Int) ->T):NDArray<T>
fillLinear funNDArray<Double>.fillLinear(f: (idx:Int) ->Double):NDArray<Double>
fun <T>NDArray<T>.fillLinear(f: (idx:Int) ->T):NDArray<T>
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 funMatrix<Double>.forEachIndexed(f: (row:Int, col:Int, ele:Double) ->Unit):Unit
fun <T>Matrix<T>.forEachIndexed(f: (row:Int, col:Int, ele:T) ->Unit):Unit
Passes each element in row major order into a function along with its index location.funNDArray<Double>.forEachIndexed(f: (idx:Int, ele:Double) ->Unit):Unit
fun <T>NDArray<T>.forEachIndexed(f: (idx:Int, ele:T) ->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 funNDArray<Double>.forEachIndexedN(f: (idx:IntArray, ele:Double) ->Unit):Unit
fun <T>NDArray<T>.forEachIndexedN(f: (idx:IntArray, ele:T) ->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 funMatrix<Double>.mapIndexed(f: (row:Int, col:Int, ele:Double) ->Double):Matrix<Double>
fun <T>Matrix<T>.mapIndexed(f: (row:Int, col:Int, ele: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.funNDArray<Double>.mapIndexed(f: (idx:Int, ele:Double) ->Double):NDArray<Double>
fun <T>NDArray<T>.mapIndexed(f: (idx:Int, ele:T) ->T):DefaultGenericNDArray<T>
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 funNDArray<Double>.mapIndexedN(f: (idx:IntArray, ele:Double) ->Double):NDArray<Double>
fun <T>NDArray<T>.mapIndexedN(f: (idx:IntArray, ele:T) ->T):NDArray<T>
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 funNDArray<Double>.minus(other:Double):NDArray<Double>
operator funNDArray<Double>.minus(other:NDArray<Double>):NDArray<Double>``operator funMatrix<Double>.minus(value:Int):Matrix<Double>
Allow operator overloading with non-Double scalars
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 funNDArray<Double>.plus(other:Double):NDArray<Double>
operator funNDArray<Double>.plus(other:NDArray<Double>):NDArray<Double>``operator funMatrix<Double>.plus(value:Int):Matrix<Double>
Allow operator overloading with non-Double scalars
pow infix funNDArray<Double>.pow(exponent:Int):NDArray<Double>
safeNIdxToLinear fun <T>NDArray<T>.safeNIdxToLinear(indices:IntArray):Int
set operator funMatrix<Double>.set(i:Int, v:Double):Unit
operator fun <T>Matrix<T>.set(i:Int, v:T):Unit
Set the ith element in the matrix. If 2D, selects elements in row-major order.operator funMatrix<Double>.set(i:Int, j:Int, v:Double):Unit
operator funMatrix<Double>.set(rows:IntRange, cols:IntRange, value:Double):Unit
operator funMatrix<Double>.set(rows:Int, cols:IntRange, value:Double):Unit
operator funMatrix<Double>.set(rows:IntRange, cols:Int, value:Double):Unit
operator funMatrix<Double>.set(i:Int, v:Int):Unit
operator funMatrix<Double>.set(i:Int, j:Int, v:Int):Unit
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 funNDArray<Double>.set(vararg indices:Int, value:NDArray<Double>):Unit
operator funNDArray<Double>.set(vararg indices:Int, value:Double):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):Unitoperator funMatrix<Double>.set(rows:IntRange, cols:IntRange, value:Matrix<Double>):Unit
operator fun <T>Matrix<T>.set(rows:IntRange, cols:IntRange, value:Matrix<T>):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 funMatrix<Double>.set(rows:Int, cols:IntRange, value:Matrix<Double>):Unit
operator fun <T>Matrix<T>.set(rows:Int, cols:IntRange, value:Matrix<T>):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 funMatrix<Double>.set(rows:IntRange, cols:Int, value:Matrix<Double>):Unit
operator fun <T>Matrix<T>.set(rows:IntRange, cols:Int, value:Matrix<T>):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 funNDArray<Double>.times(other:NDArray<Double>):NDArray<Double>
operator funNDArray<Double>.times(other:Double):NDArray<Double>``operator funMatrix<Double>.times(other:Int):Matrix<Double>
Multiply a scalar by a matrix
toDoubleArray funNDArray<Double>.toDoubleArray():DoubleArray
Converts this NDArray into a one-dimensional DoubleArray in row-major order.
toMatrix funNDArray<Double>.toMatrix():Matrix<Double>
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 funNDArray<Double>.unaryMinus():NDArray<Double>
validate funMatrix<Double>.validate(fn:ValidationContext.() ->Unit):Unit
Use the given fn to validate a matrix. Return either the matrix itself or a copy that has been transformed to match the validation rules.funMatrix<Double>.validate(name:String, fn:ValidationContext.() ->Unit):Unit
Use the given fn to validate a matrix with the given name. Return either the matrix itself or a copy that has been transformed to match the validation rules.
widthOfDims fun <T>NDArray<T>.widthOfDims():ArrayList<Int>

Inheritors

Name Summary
CBlasMatrix class CBlasMatrix :Matrix<Double>,DoubleMatrixBase
An implementation of the Matrix interface using raw cblas calls.
EJMLMatrix class EJMLMatrix :Matrix<Double>,DoubleMatrixBase
An implementation of the Matrix interface using EJML. You should rarely construct this class directly, instead make one via the top-level functions in creators.kt (e.g. zeros(5,5)) or EJMLMatrixFactory.
JBlasMatrix class JBlasMatrix :Matrix<Double>,DoubleMatrixBase
An implementation of the Matrix interface using jBlas. You should rarely construct this class directly, instead make one via the top-level functions in creators.kt (e.g. zeros(5,5)) or JBlasMatrixFactory.
MTJMatrix class MTJMatrix :Matrix<Double>,DoubleMatrixBase
An implementation of the Matrix interface using MTJ. You should rarely construct this class directly, instead make one via the top-level functions in creators.kt (e.g. zeros(5,5)) or MTJMatrixFactory.