0.1.4-dev-4 #86

Merged
altavir merged 38 commits from dev into master 2020-04-30 11:36:59 +03:00
5 changed files with 19 additions and 6 deletions
Showing only changes of commit 2d71452341 - Show all commits

View File

@ -19,13 +19,11 @@ interface Dimension {
}
}
}
inline fun <reified D : Dimension> dim(): UInt {
return D::class.objectInstance?.dim ?: error("Dimension object must be a singleton")
}
}
}
expect inline fun <reified D : Dimension> Dimension.Companion.dim(): UInt
object D1 : Dimension {
override val dim: UInt = 1u
}

View File

@ -66,7 +66,8 @@ interface DPoint<T, D : Dimension> : Point<T> {
/**
* Dimension-safe point wrapper
*/
inline class DPointWrapper<T, D : Dimension>(val point: Point<T>) : DPoint<T, D> {
inline class DPointWrapper<T, D : Dimension>(val point: Point<T>) :
DPoint<T, D> {
override val size: Int get() = point.size
override fun get(index: Int): T = point[index]
@ -94,7 +95,12 @@ inline class DMatrixContext<T : Any, Ri : Ring<T>>(val context: GenericMatrixCon
inline fun <reified D : Dimension> point(noinline initializer: (Int) -> T): DPoint<T, D> {
val size = Dimension.dim<D>()
return DPoint.coerceUnsafe(context.point(size.toInt(), initializer))
return DPoint.coerceUnsafe(
context.point(
size.toInt(),
initializer
)
)
}
inline infix fun <reified R1 : Dimension, reified C1 : Dimension, reified C2 : Dimension> DMatrix<T, R1, C1>.dot(

View File

@ -0,0 +1,5 @@
package scientifik.kmath.dimensions
actual inline fun <reified D : Dimension> Dimension.Companion.dim(): UInt {
TODO("KClass::objectInstance does not work")
}

View File

@ -0,0 +1,4 @@
package scientifik.kmath.dimensions
actual inline fun <reified D : Dimension> Dimension.Companion.dim(): UInt =
D::class.objectInstance?.dim ?: error("Dimension object must be a singleton")