Update features

This commit is contained in:
Iaroslav 2020-09-14 20:02:53 +07:00
parent 1c495759cd
commit a046f5c060
No known key found for this signature in database
GPG Key ID: 46E15E4A31B3BCD7

View File

@ -24,12 +24,10 @@ class EjmlMatrix(val origin: SimpleMatrix, features: Set<MatrixFeature>? = null)
get() = intArrayOf(origin.numRows(), origin.numCols()) get() = intArrayOf(origin.numRows(), origin.numCols())
override val features: Set<MatrixFeature> = hashSetOf( override val features: Set<MatrixFeature> = hashSetOf(
object : DeterminantFeature<Double> { object : LUPDecompositionFeature<Double>, DeterminantFeature<Double> {
override val determinant: Double override val determinant: Double
get() = origin.determinant() get() = origin.determinant()
},
object : LUPDecompositionFeature<Double> {
private val lup by lazy { private val lup by lazy {
val ludecompositionF64 = DecompositionFactory_DDRM.lu(origin.numRows(), origin.numCols()) val ludecompositionF64 = DecompositionFactory_DDRM.lu(origin.numRows(), origin.numCols())
.also { it.decompose(origin.ddrm.copy()) } .also { it.decompose(origin.ddrm.copy()) }
@ -50,7 +48,7 @@ class EjmlMatrix(val origin: SimpleMatrix, features: Set<MatrixFeature>? = null)
override val p: FeaturedMatrix<Double> override val p: FeaturedMatrix<Double>
get() = lup.first get() = lup.first
} }
).addAll(features) ).addAll(features.orEmpty())
override fun suggestFeature(vararg features: MatrixFeature): FeaturedMatrix<Double> = override fun suggestFeature(vararg features: MatrixFeature): FeaturedMatrix<Double> =
EjmlMatrix(origin, this.features + features) EjmlMatrix(origin, this.features + features)