api / koma.matrix / MatrixFactory

MatrixFactory

interface MatrixFactory<out T :Matrix<*>>

A set of constructors that must be implemented by a koma backend. Generates various types of matrices. Generic parameter is the type of element, i.e. T=Matrix or T=Matrix, etc.

Functions

Name Summary
arange abstract fun arange(start:Double, stop:Double, increment:Double):T
abstract fun arange(start:Int, stop:Int, increment:Int):T
Creates a row-vector with the first value of start and the last value of stop, with increment steps between each value.abstract fun arange(start:Double, stop:Double):T
abstract fun arange(start:Int, stop:Int):T
Creates a row-vector with the first value of start and the last value of stop, with unit steps between each value.
create abstract fun create(data:IntRange):T
Creates a row-vector with initial values pulled from an int range, e.g. 1..45abstract fun create(data:DoubleArray):T
Creates a row-vector with initial values pulled from a double arrayabstract fun create(data:Array<DoubleArray>):T
Creates a matrix from an array of arrays (row-major)
eye abstract fun eye(size:Int):T
Creates an identity matrix of the requested shapeabstract fun eye(rows:Int, cols:Int):T
Creates an identity matrix of the requested shape, with zero padding if the axis lengths arent equal.
ones abstract fun ones(rows:Int, cols:Int):T
Creates a one initialized matrix of the requested shape
rand abstract fun rand(rows:Int, cols:Int):T
Creates a matrix of uniform 0-1 random samples
randn abstract fun randn(rows:Int, cols:Int):T
Creates a matrix of unit-normal random samples
zeros abstract fun zeros(rows:Int, cols:Int):T
Generate a zero initialized matrix of the requested shape.

Inheritors

Name Summary
DefaultDoubleMatrixFactory class DefaultDoubleMatrixFactory :MatrixFactory<Matrix<Double>>
DefaultFloatMatrixFactory class DefaultFloatMatrixFactory :MatrixFactory<Matrix<Float>>
DefaultIntMatrixFactory class DefaultIntMatrixFactory :MatrixFactory<Matrix<Int>>
DoubleFactoryBase abstract class DoubleFactoryBase<T :Matrix<Double>> :MatrixFactory<T>
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.