Package space.kscience.kmath.linear

Types

Link copied to clipboard
class BufferedLinearSpace<T, out A : Ring<T>>(bufferAlgebra: BufferAlgebra<T, A>) : LinearSpace<T, A>
Link copied to clipboard
interface CholeskyDecompositionFeature<out T : Any> : MatrixFeature

Matrices with this feature support Cholesky factorization: a = l · lH where a is the owning matrix.

Link copied to clipboard
interface DeterminantFeature<out T : Any> : MatrixFeature

Matrices with this feature can compute their determinant.

Link copied to clipboard
interface DiagonalFeature : MatrixFeature

Matrices with this feature are considered to have only diagonal non-null elements.

Link copied to clipboard
object DoubleLinearSpace : LinearSpace<Double, DoubleField>
Link copied to clipboard
interface InverseMatrixFeature<out T : Any> : MatrixFeature

Matrices with this feature can be inverted: inverse = a−1 where a is the owning matrix.

Link copied to clipboard
object LFeature : MatrixFeature

Matrices with this feature are lower triangular ones.

Link copied to clipboard
interface LinearSolver<T : Any>

A group of methods to solve for X in equation X = A−1 · B, where A and B are matrices or vectors.

Link copied to clipboard
interface LinearSpace<T, out A : Ring<T>>

Basic operations on matrices and vectors.

Link copied to clipboard
interface LUDecompositionFeature<out T : Any> : MatrixFeature

Matrices with this feature support LU factorization: a = l · u where a is the owning matrix.

Link copied to clipboard
class LupDecomposition<T : Any>(context: LinearSpace<T, *>, elementContext: Field<T>, lu: Matrix<T>, pivot: IntArray, even: Boolean) : LupDecompositionFeature<T> , DeterminantFeature<T>

Common implementation of LupDecompositionFeature.

Link copied to clipboard
interface LupDecompositionFeature<out T : Any> : MatrixFeature

Matrices with this feature support LU factorization with partial pivoting: p · a = l · u where a is the owning matrix.

Link copied to clipboard
typealias Matrix<T> = Structure2D<T>

Alias for Structure2D with more familiar name.

Link copied to clipboard
class MatrixBuilder<T : Any, out A : Ring<T>>(linearSpace: LinearSpace<T, A>, rows: Int, columns: Int)
Link copied to clipboard
interface MatrixFeature : StructureFeature

A marker interface representing some properties of matrices or additional transformations of them. Features are used to optimize matrix operations performance in some cases or retrieve the APIs.

Link copied to clipboard
class MatrixWrapper<out T : Any> : Structure2D<T>

A Matrix that holds MatrixFeature objects.

Link copied to clipboard
typealias MutableMatrix<T> = MutableStructure2D<T>
Link copied to clipboard
object OrthogonalFeature : MatrixFeature

Matrices with this feature are orthogonal ones: a · aT = u where a is the owning matrix, u is the unit matrix (UnitFeature).

Link copied to clipboard
typealias Point<T> = Buffer<T>

Alias or using Buffer as a point/vector in a many-dimensional space.

Link copied to clipboard
interface QRDecompositionFeature<out T : Any> : MatrixFeature

Matrices with this feature support QR factorization: a = q · r where a is the owning matrix.

Link copied to clipboard
interface SingularValueDecompositionFeature<out T : Any> : MatrixFeature

Matrices with this feature support SVD: a = u · s · vH where a is the owning matrix.

Link copied to clipboard
object SymmetricMatrixFeature : MatrixFeature
Link copied to clipboard
class TransposedFeature<out T : Any>(original: Matrix<T>) : MatrixFeature
Link copied to clipboard
object UFeature : MatrixFeature

Matrices with this feature are upper triangular ones.

Link copied to clipboard
object UnitFeature : DiagonalFeature

Matrices with this feature have unit elements on diagonal and zero elements in all other places.

Link copied to clipboard
class VirtualMatrix<out T : Any>(rowNum: Int, colNum: Int, generator: (i: Int, j: Int) -> T) : Structure2D<T>

The matrix where each element is evaluated each time when is being accessed.

Link copied to clipboard
object ZeroFeature : DiagonalFeature

Matrices with this feature have all zero elements.

Functions

Link copied to clipboard
fun <T : Any> Point<T>.asMatrix(): VirtualMatrix<T>

Creates an n × 1 VirtualMatrix, where n is the size of the given buffer.

Link copied to clipboard
fun <T : Any> Matrix<T>.asVector(): Point<T>

Convert matrix to vector if it is possible.

Link copied to clipboard
fun <T : Any> LinearSpace<T, Ring<T>>.column(vararg values: T): Matrix<T>
inline fun <T : Any> LinearSpace<T, Ring<T>>.column(size: Int, crossinline builder: (Int) -> T): Matrix<T>
Link copied to clipboard
inline fun <T : Any, F : StructureFeature> LinearSpace<T, *>.computeFeature(structure: Matrix<T>): F?

Get a feature of the structure in this scope. Structure features take precedence other context features.

Link copied to clipboard
fun <T : Any> DeterminantFeature(determinant: T): DeterminantFeature<T>
Link copied to clipboard
inline operator fun <LS : LinearSpace<*, *>, R> LS.invoke(block: LS.() -> R): R
Link copied to clipboard
fun <T, A : Ring<T>> A.linearSpace(bufferFactory: BufferFactory<T>): BufferedLinearSpace<T, A>
Link copied to clipboard
inline fun <T : Comparable<T>> LinearSpace<T, Field<T>>.lup(matrix: Matrix<T>, noinline checkSingular: (T) -> Boolean): LupDecomposition<T>
fun LinearSpace<Double, DoubleField>.lup(matrix: Matrix<Double>, singularityThreshold: Double = 1.0E-11): LupDecomposition<Double>

fun <T : Comparable<T>> LinearSpace<T, Field<T>>.lup(factory: MutableBufferFactory<T>, matrix: Matrix<T>, checkSingular: (T) -> Boolean): LupDecomposition<T>

Create a lup decomposition of generic matrix.

Link copied to clipboard
fun LinearSpace<Double, DoubleField>.lupSolver(singularityThreshold: Double = 1.0E-11): LinearSolver<Double>

fun <T : Comparable<T>, F : Field<T>> LinearSpace<T, F>.lupSolver(bufferFactory: MutableBufferFactory<T>, singularityCheck: (T) -> Boolean): LinearSolver<T>

Produce a generic solver based on LUP decomposition

Link copied to clipboard
fun <T : Any, A : Ring<T>> LinearSpace<T, A>.matrix(rows: Int, columns: Int): MatrixBuilder<T, A>

Create a matrix builder with given number of rows and columns

Link copied to clipboard
fun <T : Any> LinearSpace<T, Ring<T>>.one(rows: Int, columns: Int): Matrix<T>

Diagonal matrix of ones. The matrix is virtual no actual matrix is created.

Link copied to clipboard
operator fun <T : Any> Matrix<T>.plus(newFeature: MatrixFeature): MatrixWrapper<T>
Link copied to clipboard
fun <T : Any> LinearSpace<T, Ring<T>>.row(vararg values: T): Matrix<T>
inline fun <T : Any> LinearSpace<T, Ring<T>>.row(size: Int, crossinline builder: (Int) -> T): Matrix<T>
Link copied to clipboard
fun <T : Any, A : Ring<T>> MatrixBuilder<T, A>.symmetric(builder: (i: Int, j: Int) -> T): Matrix<T>

Naive implementation of a symmetric matrix builder, that adds a SymmetricMatrixFeature tag. The resulting matrix contains full size^2 number of elements, but caches elements during calls to save builder calls. builder is always called in the upper triangle region meaning that i <= j

Link copied to clipboard
fun <T : Any> Matrix<T>.transpose(): Matrix<T>

Create a virtual transposed matrix without copying anything. A.transpose().transpose() === A

Link copied to clipboard
fun <T : Any> LinearSpace<T, Ring<T>>.vector(vararg elements: T): Point<T>
Link copied to clipboard
fun <T : Any> MatrixBuilder<T, *>.virtual(generator: (i: Int, j: Int) -> T): VirtualMatrix<T>
Link copied to clipboard
fun <T : Any> Matrix<T>.withFeature(newFeature: MatrixFeature): MatrixWrapper<T>

Add a single feature to a Matrix

Link copied to clipboard
fun <T : Any> Matrix<T>.withFeatures(newFeatures: Iterable<MatrixFeature>): MatrixWrapper<T>

Add a collection of features to a Matrix

Link copied to clipboard
fun <T : Any> LinearSpace<T, Ring<T>>.zero(rows: Int, columns: Int): Matrix<T>

A virtual matrix of zeroes

Properties

Link copied to clipboard
val DoubleField.linearSpace: DoubleLinearSpace
Link copied to clipboard
val <T : Any> Matrix<T>.origin: Matrix<T>

Return the original matrix. If this is a wrapper, return its origin. If not, this matrix. Origin does not necessary store all features.