Minor: micro-optimize getFeature function, reformat
This commit is contained in:
parent
3f00410fc1
commit
f1b319f73d
@ -60,8 +60,9 @@ public inline fun <reified T : Any> Matrix<*>.hasFeature(): Boolean =
|
||||
/**
|
||||
* Get the first feature matching given class. Does not guarantee that matrix has only one feature matching the criteria
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
public inline fun <reified T : Any> Matrix<*>.getFeature(): T? =
|
||||
features.filterIsInstance<T>().firstOrNull()
|
||||
features.find { it is T }?.let { it as T }
|
||||
|
||||
/**
|
||||
* Diagonal matrix of ones. The matrix is virtual no actual matrix is created
|
||||
@ -78,7 +79,12 @@ public fun <T : Any, R : Ring<T>> GenericMatrixContext<T, R, *>.one(rows: Int, c
|
||||
public fun <T : Any, R : Ring<T>> GenericMatrixContext<T, R, *>.zero(rows: Int, columns: Int): FeaturedMatrix<T> =
|
||||
VirtualMatrix(rows, columns) { _, _ -> elementContext.zero }
|
||||
|
||||
public class TransposedFeature<T : Any>(public val original: Matrix<T>) : MatrixFeature
|
||||
/**
|
||||
* Matrices with this feature were transposed previosly and hold the reference to their original.
|
||||
*
|
||||
* @property original the matrix before transposition.
|
||||
*/
|
||||
public inline class TransposedFeature<T : Any>(public val original: Matrix<T>) : MatrixFeature
|
||||
|
||||
/**
|
||||
* Create a virtual transposed matrix without copying anything. `A.transpose().transpose() === A`.
|
||||
|
Loading…
Reference in New Issue
Block a user