Replace opt-in annotations with useExperimentalAnnotation for modules
This commit is contained in:
parent
1b8ddedfe3
commit
40888f66d6
@ -56,6 +56,12 @@ benchmark {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kotlin.sourceSets.all {
|
||||||
|
with(languageSettings) {
|
||||||
|
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
||||||
|
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinCompile> {
|
tasks.withType<KotlinCompile> {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package scientifik.kmath.utils
|
package scientifik.kmath.utils
|
||||||
|
|
||||||
import kotlin.contracts.ExperimentalContracts
|
|
||||||
import kotlin.contracts.InvocationKind
|
import kotlin.contracts.InvocationKind
|
||||||
import kotlin.contracts.contract
|
import kotlin.contracts.contract
|
||||||
import kotlin.system.measureTimeMillis
|
import kotlin.system.measureTimeMillis
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
internal inline fun measureAndPrint(title: String, block: () -> Unit) {
|
internal inline fun measureAndPrint(title: String, block: () -> Unit) {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
val time = measureTimeMillis(block)
|
val time = measureTimeMillis(block)
|
||||||
|
@ -8,7 +8,6 @@ import kotlin.contracts.InvocationKind
|
|||||||
import kotlin.contracts.contract
|
import kotlin.contracts.contract
|
||||||
import kotlin.system.measureTimeMillis
|
import kotlin.system.measureTimeMillis
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
internal inline fun measureAndPrint(title: String, block: () -> Unit) {
|
internal inline fun measureAndPrint(title: String, block: () -> Unit) {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
val time = measureTimeMillis(block)
|
val time = measureTimeMillis(block)
|
||||||
|
@ -16,7 +16,6 @@ fun DMatrixContext<Double, RealField>.simple() {
|
|||||||
|
|
||||||
|
|
||||||
object D5 : Dimension {
|
object D5 : Dimension {
|
||||||
@OptIn(ExperimentalUnsignedTypes::class)
|
|
||||||
override val dim: UInt = 5u
|
override val dim: UInt = 5u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
plugins { id("scientifik.mpp") }
|
plugins { id("scientifik.mpp") }
|
||||||
|
|
||||||
kotlin.sourceSets {
|
kotlin.sourceSets {
|
||||||
// all {
|
all { languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts") }
|
||||||
// languageSettings.apply{
|
|
||||||
// enableLanguageFeature("NewInference")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
commonMain {
|
commonMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
api(project(":kmath-core"))
|
api(project(":kmath-core"))
|
||||||
|
@ -41,7 +41,6 @@ inline fun <reified T : Any, A : Algebra<T>, E : Algebra<MST>> A.mst(
|
|||||||
/**
|
/**
|
||||||
* Builds [MstExpression] over [Space].
|
* Builds [MstExpression] over [Space].
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <reified T : Any> Space<T>.mstInSpace(block: MstSpace.() -> MST): MstExpression<T> {
|
inline fun <reified T : Any> Space<T>.mstInSpace(block: MstSpace.() -> MST): MstExpression<T> {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return MstExpression(this, MstSpace.block())
|
return MstExpression(this, MstSpace.block())
|
||||||
@ -50,7 +49,6 @@ inline fun <reified T : Any> Space<T>.mstInSpace(block: MstSpace.() -> MST): Mst
|
|||||||
/**
|
/**
|
||||||
* Builds [MstExpression] over [Ring].
|
* Builds [MstExpression] over [Ring].
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <reified T : Any> Ring<T>.mstInRing(block: MstRing.() -> MST): MstExpression<T> {
|
inline fun <reified T : Any> Ring<T>.mstInRing(block: MstRing.() -> MST): MstExpression<T> {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return MstExpression(this, MstRing.block())
|
return MstExpression(this, MstRing.block())
|
||||||
@ -59,7 +57,6 @@ inline fun <reified T : Any> Ring<T>.mstInRing(block: MstRing.() -> MST): MstExp
|
|||||||
/**
|
/**
|
||||||
* Builds [MstExpression] over [Field].
|
* Builds [MstExpression] over [Field].
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <reified T : Any> Field<T>.mstInField(block: MstField.() -> MST): MstExpression<T> {
|
inline fun <reified T : Any> Field<T>.mstInField(block: MstField.() -> MST): MstExpression<T> {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return MstExpression(this, MstField.block())
|
return MstExpression(this, MstField.block())
|
||||||
@ -68,7 +65,6 @@ inline fun <reified T : Any> Field<T>.mstInField(block: MstField.() -> MST): Mst
|
|||||||
/**
|
/**
|
||||||
* Builds [MstExpression] over [ExtendedField].
|
* Builds [MstExpression] over [ExtendedField].
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <reified T : Any> Field<T>.mstInExtendedField(block: MstExtendedField.() -> MST): MstExpression<T> {
|
inline fun <reified T : Any> Field<T>.mstInExtendedField(block: MstExtendedField.() -> MST): MstExpression<T> {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return MstExpression(this, MstExtendedField.block())
|
return MstExpression(this, MstExtendedField.block())
|
||||||
@ -77,7 +73,6 @@ inline fun <reified T : Any> Field<T>.mstInExtendedField(block: MstExtendedField
|
|||||||
/**
|
/**
|
||||||
* Builds [MstExpression] over [FunctionalExpressionSpace].
|
* Builds [MstExpression] over [FunctionalExpressionSpace].
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <reified T : Any, A : Space<T>> FunctionalExpressionSpace<T, A>.mstInSpace(block: MstSpace.() -> MST): MstExpression<T> {
|
inline fun <reified T : Any, A : Space<T>> FunctionalExpressionSpace<T, A>.mstInSpace(block: MstSpace.() -> MST): MstExpression<T> {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return algebra.mstInSpace(block)
|
return algebra.mstInSpace(block)
|
||||||
@ -86,8 +81,6 @@ inline fun <reified T : Any, A : Space<T>> FunctionalExpressionSpace<T, A>.mstIn
|
|||||||
/**
|
/**
|
||||||
* Builds [MstExpression] over [FunctionalExpressionRing].
|
* Builds [MstExpression] over [FunctionalExpressionRing].
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <reified T : Any, A : Ring<T>> FunctionalExpressionRing<T, A>.mstInRing(block: MstRing.() -> MST): MstExpression<T> {
|
inline fun <reified T : Any, A : Ring<T>> FunctionalExpressionRing<T, A>.mstInRing(block: MstRing.() -> MST): MstExpression<T> {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return algebra.mstInRing(block)
|
return algebra.mstInRing(block)
|
||||||
@ -96,7 +89,6 @@ inline fun <reified T : Any, A : Ring<T>> FunctionalExpressionRing<T, A>.mstInRi
|
|||||||
/**
|
/**
|
||||||
* Builds [MstExpression] over [FunctionalExpressionField].
|
* Builds [MstExpression] over [FunctionalExpressionField].
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <reified T : Any, A : Field<T>> FunctionalExpressionField<T, A>.mstInField(block: MstField.() -> MST): MstExpression<T> {
|
inline fun <reified T : Any, A : Field<T>> FunctionalExpressionField<T, A>.mstInField(block: MstField.() -> MST): MstExpression<T> {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return algebra.mstInField(block)
|
return algebra.mstInField(block)
|
||||||
@ -105,7 +97,6 @@ inline fun <reified T : Any, A : Field<T>> FunctionalExpressionField<T, A>.mstIn
|
|||||||
/**
|
/**
|
||||||
* Builds [MstExpression] over [FunctionalExpressionExtendedField].
|
* Builds [MstExpression] over [FunctionalExpressionExtendedField].
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <reified T : Any, A : ExtendedField<T>> FunctionalExpressionExtendedField<T, A>.mstInExtendedField(block: MstExtendedField.() -> MST): MstExpression<T> {
|
inline fun <reified T : Any, A : ExtendedField<T>> FunctionalExpressionExtendedField<T, A>.mstInExtendedField(block: MstExtendedField.() -> MST): MstExpression<T> {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return algebra.mstInExtendedField(block)
|
return algebra.mstInExtendedField(block)
|
||||||
|
@ -29,7 +29,6 @@ internal val KClass<*>.asm: Type
|
|||||||
/**
|
/**
|
||||||
* Returns singleton array with this value if the [predicate] is true, returns empty array otherwise.
|
* Returns singleton array with this value if the [predicate] is true, returns empty array otherwise.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
internal inline fun <reified T> T.wrapToArrayIf(predicate: (T) -> Boolean): Array<T> {
|
internal inline fun <reified T> T.wrapToArrayIf(predicate: (T) -> Boolean): Array<T> {
|
||||||
contract { callsInPlace(predicate, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(predicate, InvocationKind.EXACTLY_ONCE) }
|
||||||
return if (predicate(this)) arrayOf(this) else emptyArray()
|
return if (predicate(this)) arrayOf(this) else emptyArray()
|
||||||
@ -43,7 +42,6 @@ private fun MethodVisitor.instructionAdapter(): InstructionAdapter = Instruction
|
|||||||
/**
|
/**
|
||||||
* Creates an [InstructionAdapter] from this [MethodVisitor] and applies [block] to it.
|
* Creates an [InstructionAdapter] from this [MethodVisitor] and applies [block] to it.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
internal inline fun MethodVisitor.instructionAdapter(block: InstructionAdapter.() -> Unit): InstructionAdapter {
|
internal inline fun MethodVisitor.instructionAdapter(block: InstructionAdapter.() -> Unit): InstructionAdapter {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return instructionAdapter().apply(block)
|
return instructionAdapter().apply(block)
|
||||||
@ -72,14 +70,12 @@ internal tailrec fun buildName(mst: MST, collision: Int = 0): String {
|
|||||||
return buildName(mst, collision + 1)
|
return buildName(mst, collision + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
@Suppress("FunctionName")
|
@Suppress("FunctionName")
|
||||||
internal inline fun ClassWriter(flags: Int, block: ClassWriter.() -> Unit): ClassWriter {
|
internal inline fun ClassWriter(flags: Int, block: ClassWriter.() -> Unit): ClassWriter {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return ClassWriter(flags).apply(block)
|
return ClassWriter(flags).apply(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
internal inline fun ClassWriter.visitField(
|
internal inline fun ClassWriter.visitField(
|
||||||
access: Int,
|
access: Int,
|
||||||
name: String,
|
name: String,
|
||||||
@ -167,7 +163,6 @@ private fun <T> AsmBuilder<T>.tryInvokeSpecific(
|
|||||||
/**
|
/**
|
||||||
* Builds specialized algebra call with option to fallback to generic algebra operation accepting String.
|
* Builds specialized algebra call with option to fallback to generic algebra operation accepting String.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
internal inline fun <T> AsmBuilder<T>.buildAlgebraOperationCall(
|
internal inline fun <T> AsmBuilder<T>.buildAlgebraOperationCall(
|
||||||
context: Algebra<T>,
|
context: Algebra<T>,
|
||||||
name: String,
|
name: String,
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
plugins {
|
plugins { id("scientifik.jvm") }
|
||||||
id("scientifik.jvm")
|
|
||||||
}
|
|
||||||
|
|
||||||
description = "Commons math binding for kmath"
|
description = "Commons math binding for kmath"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -10,4 +7,6 @@ dependencies {
|
|||||||
api(project(":kmath-prob"))
|
api(project(":kmath-prob"))
|
||||||
api(project(":kmath-functions"))
|
api(project(":kmath-functions"))
|
||||||
api("org.apache.commons:commons-math3:3.6.1")
|
api("org.apache.commons:commons-math3:3.6.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kotlin.sourceSets.all { languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts") }
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package scientifik.kmath.commons.expressions
|
package scientifik.kmath.commons.expressions
|
||||||
|
|
||||||
import scientifik.kmath.expressions.invoke
|
import scientifik.kmath.expressions.invoke
|
||||||
import kotlin.contracts.ExperimentalContracts
|
|
||||||
import kotlin.contracts.InvocationKind
|
import kotlin.contracts.InvocationKind
|
||||||
import kotlin.contracts.contract
|
import kotlin.contracts.contract
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <R> diff(order: Int, vararg parameters: Pair<String, Double>, block: DerivativeStructureField.() -> R): R {
|
inline fun <R> diff(order: Int, vararg parameters: Pair<String, Double>, block: DerivativeStructureField.() -> R): R {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return DerivativeStructureField(order, mapOf(*parameters)).run(block)
|
return DerivativeStructureField(order, mapOf(*parameters)).run(block)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
plugins { id("scientifik.mpp") }
|
plugins { id("scientifik.mpp") }
|
||||||
|
|
||||||
kotlin.sourceSets {
|
kotlin.sourceSets {
|
||||||
commonMain {
|
all { languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts") }
|
||||||
dependencies { api(project(":kmath-memory")) }
|
commonMain { dependencies { api(project(":kmath-memory")) } }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import kotlin.contracts.contract
|
|||||||
/**
|
/**
|
||||||
* Creates a functional expression with this [Space].
|
* Creates a functional expression with this [Space].
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <T> Space<T>.spaceExpression(block: FunctionalExpressionSpace<T, Space<T>>.() -> Expression<T>): Expression<T> {
|
inline fun <T> Space<T>.spaceExpression(block: FunctionalExpressionSpace<T, Space<T>>.() -> Expression<T>): Expression<T> {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return FunctionalExpressionSpace(this).block()
|
return FunctionalExpressionSpace(this).block()
|
||||||
@ -20,7 +19,6 @@ inline fun <T> Space<T>.spaceExpression(block: FunctionalExpressionSpace<T, Spac
|
|||||||
/**
|
/**
|
||||||
* Creates a functional expression with this [Ring].
|
* Creates a functional expression with this [Ring].
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <T> Ring<T>.ringExpression(block: FunctionalExpressionRing<T, Ring<T>>.() -> Expression<T>): Expression<T> {
|
inline fun <T> Ring<T>.ringExpression(block: FunctionalExpressionRing<T, Ring<T>>.() -> Expression<T>): Expression<T> {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return FunctionalExpressionRing(this).block()
|
return FunctionalExpressionRing(this).block()
|
||||||
@ -29,7 +27,6 @@ inline fun <T> Ring<T>.ringExpression(block: FunctionalExpressionRing<T, Ring<T>
|
|||||||
/**
|
/**
|
||||||
* Creates a functional expression with this [Field].
|
* Creates a functional expression with this [Field].
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <T> Field<T>.fieldExpression(block: FunctionalExpressionField<T, Field<T>>.() -> Expression<T>): Expression<T> {
|
inline fun <T> Field<T>.fieldExpression(block: FunctionalExpressionField<T, Field<T>>.() -> Expression<T>): Expression<T> {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return FunctionalExpressionField(this).block()
|
return FunctionalExpressionField(this).block()
|
||||||
@ -38,7 +35,6 @@ inline fun <T> Field<T>.fieldExpression(block: FunctionalExpressionField<T, Fiel
|
|||||||
/**
|
/**
|
||||||
* Creates a functional expression with this [ExtendedField].
|
* Creates a functional expression with this [ExtendedField].
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <T> ExtendedField<T>.extendedFieldExpression(block: FunctionalExpressionExtendedField<T, ExtendedField<T>>.() -> Expression<T>): Expression<T> {
|
inline fun <T> ExtendedField<T>.extendedFieldExpression(block: FunctionalExpressionExtendedField<T, ExtendedField<T>>.() -> Expression<T>): Expression<T> {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return FunctionalExpressionExtendedField(this).block()
|
return FunctionalExpressionExtendedField(this).block()
|
||||||
|
@ -28,7 +28,6 @@ interface FeaturedMatrix<T : Any> : Matrix<T> {
|
|||||||
companion object
|
companion object
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun Structure2D.Companion.real(rows: Int, columns: Int, initializer: (Int, Int) -> Double): Matrix<Double> {
|
inline fun Structure2D.Companion.real(rows: Int, columns: Int, initializer: (Int, Int) -> Double): Matrix<Double> {
|
||||||
contract { callsInPlace(initializer) }
|
contract { callsInPlace(initializer) }
|
||||||
return MatrixContext.real.produce(rows, columns, initializer)
|
return MatrixContext.real.produce(rows, columns, initializer)
|
||||||
|
@ -55,7 +55,6 @@ class DerivationResult<T : Any>(
|
|||||||
* assertEquals(9.0, x.d) // dy/dx
|
* assertEquals(9.0, x.d) // dy/dx
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <T : Any, F : Field<T>> F.deriv(body: AutoDiffField<T, F>.() -> Variable<T>): DerivationResult<T> {
|
inline fun <T : Any, F : Field<T>> F.deriv(body: AutoDiffField<T, F>.() -> Variable<T>): DerivationResult<T> {
|
||||||
contract { callsInPlace(body, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(body, InvocationKind.EXACTLY_ONCE) }
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import kotlin.jvm.JvmName
|
|||||||
* @param R the type of resulting iterable.
|
* @param R the type of resulting iterable.
|
||||||
* @param initial lazy evaluated.
|
* @param initial lazy evaluated.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <T, R> Iterator<T>.cumulative(initial: R, crossinline operation: (R, T) -> R): Iterator<R> {
|
inline fun <T, R> Iterator<T>.cumulative(initial: R, crossinline operation: (R, T) -> R): Iterator<R> {
|
||||||
contract { callsInPlace(operation) }
|
contract { callsInPlace(operation) }
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import kotlin.math.max
|
|||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
import kotlin.math.sign
|
import kotlin.math.sign
|
||||||
|
|
||||||
|
|
||||||
typealias Magnitude = UIntArray
|
typealias Magnitude = UIntArray
|
||||||
typealias TBase = ULong
|
typealias TBase = ULong
|
||||||
|
|
||||||
@ -487,13 +486,11 @@ fun String.parseBigInteger(): BigInt? {
|
|||||||
return res * sign
|
return res * sign
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun Buffer.Companion.bigInt(size: Int, initializer: (Int) -> BigInt): Buffer<BigInt> {
|
inline fun Buffer.Companion.bigInt(size: Int, initializer: (Int) -> BigInt): Buffer<BigInt> {
|
||||||
contract { callsInPlace(initializer) }
|
contract { callsInPlace(initializer) }
|
||||||
return boxing(size, initializer)
|
return boxing(size, initializer)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun MutableBuffer.Companion.bigInt(size: Int, initializer: (Int) -> BigInt): MutableBuffer<BigInt> {
|
inline fun MutableBuffer.Companion.bigInt(size: Int, initializer: (Int) -> BigInt): MutableBuffer<BigInt> {
|
||||||
contract { callsInPlace(initializer) }
|
contract { callsInPlace(initializer) }
|
||||||
return boxing(size, initializer)
|
return boxing(size, initializer)
|
||||||
|
@ -198,13 +198,11 @@ data class Complex(val re: Double, val im: Double) : FieldElement<Complex, Compl
|
|||||||
*/
|
*/
|
||||||
fun Number.toComplex(): Complex = Complex(this, 0.0)
|
fun Number.toComplex(): Complex = Complex(this, 0.0)
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun Buffer.Companion.complex(size: Int, crossinline init: (Int) -> Complex): Buffer<Complex> {
|
inline fun Buffer.Companion.complex(size: Int, crossinline init: (Int) -> Complex): Buffer<Complex> {
|
||||||
contract { callsInPlace(init) }
|
contract { callsInPlace(init) }
|
||||||
return MemoryBuffer.create(Complex, size, init)
|
return MemoryBuffer.create(Complex, size, init)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun MutableBuffer.Companion.complex(size: Int, crossinline init: (Int) -> Complex): Buffer<Complex> {
|
inline fun MutableBuffer.Companion.complex(size: Int, crossinline init: (Int) -> Complex): Buffer<Complex> {
|
||||||
contract { callsInPlace(init) }
|
contract { callsInPlace(init) }
|
||||||
return MemoryBuffer.create(Complex, size, init)
|
return MemoryBuffer.create(Complex, size, init)
|
||||||
|
@ -167,7 +167,6 @@ fun <T> List<T>.asBuffer(): ListBuffer<T> = ListBuffer(this)
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an array element given its index.
|
* It should return the value for an array element given its index.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <T> ListBuffer(size: Int, init: (Int) -> T): ListBuffer<T> {
|
inline fun <T> ListBuffer(size: Int, init: (Int) -> T): ListBuffer<T> {
|
||||||
contract { callsInPlace(init) }
|
contract { callsInPlace(init) }
|
||||||
return List(size, init).asBuffer()
|
return List(size, init).asBuffer()
|
||||||
|
@ -112,7 +112,6 @@ inline fun ComplexNDElement.mapIndexed(crossinline transform: ComplexField.(inde
|
|||||||
/**
|
/**
|
||||||
* Map one [ComplexNDElement] using function without indices.
|
* Map one [ComplexNDElement] using function without indices.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun ComplexNDElement.map(crossinline transform: ComplexField.(Complex) -> Complex): ComplexNDElement {
|
inline fun ComplexNDElement.map(crossinline transform: ComplexField.(Complex) -> Complex): ComplexNDElement {
|
||||||
contract { callsInPlace(transform) }
|
contract { callsInPlace(transform) }
|
||||||
val buffer = Buffer.complex(strides.linearSize) { offset -> ComplexField.transform(buffer[offset]) }
|
val buffer = Buffer.complex(strides.linearSize) { offset -> ComplexField.transform(buffer[offset]) }
|
||||||
@ -153,7 +152,6 @@ fun NDElement.Companion.complex(vararg shape: Int, initializer: ComplexField.(In
|
|||||||
/**
|
/**
|
||||||
* Produce a context for n-dimensional operations inside this real field
|
* Produce a context for n-dimensional operations inside this real field
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <R> ComplexField.nd(vararg shape: Int, action: ComplexNDField.() -> R): R {
|
inline fun <R> ComplexField.nd(vararg shape: Int, action: ComplexNDField.() -> R): R {
|
||||||
contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) }
|
||||||
return NDField.complex(*shape).action()
|
return NDField.complex(*shape).action()
|
||||||
|
@ -66,7 +66,6 @@ class FlaggedRealBuffer(val values: DoubleArray, val flags: ByteArray) : Flagged
|
|||||||
}.iterator()
|
}.iterator()
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun FlaggedRealBuffer.forEachValid(block: (Double) -> Unit) {
|
inline fun FlaggedRealBuffer.forEachValid(block: (Double) -> Unit) {
|
||||||
contract { callsInPlace(block) }
|
contract { callsInPlace(block) }
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ inline class FloatBuffer(val array: FloatArray) : MutableBuffer<Float> {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an buffer element given its index.
|
* It should return the value for an buffer element given its index.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun FloatBuffer(size: Int, init: (Int) -> Float): FloatBuffer {
|
inline fun FloatBuffer(size: Int, init: (Int) -> Float): FloatBuffer {
|
||||||
contract { callsInPlace(init) }
|
contract { callsInPlace(init) }
|
||||||
return FloatBuffer(FloatArray(size) { init(it) })
|
return FloatBuffer(FloatArray(size) { init(it) })
|
||||||
|
@ -31,7 +31,6 @@ inline class IntBuffer(val array: IntArray) : MutableBuffer<Int> {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an buffer element given its index.
|
* It should return the value for an buffer element given its index.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun IntBuffer(size: Int, init: (Int) -> Int): IntBuffer {
|
inline fun IntBuffer(size: Int, init: (Int) -> Int): IntBuffer {
|
||||||
contract { callsInPlace(init) }
|
contract { callsInPlace(init) }
|
||||||
return IntBuffer(IntArray(size) { init(it) })
|
return IntBuffer(IntArray(size) { init(it) })
|
||||||
|
@ -31,7 +31,6 @@ inline class LongBuffer(val array: LongArray) : MutableBuffer<Long> {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an buffer element given its index.
|
* It should return the value for an buffer element given its index.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun LongBuffer(size: Int, init: (Int) -> Long): LongBuffer {
|
inline fun LongBuffer(size: Int, init: (Int) -> Long): LongBuffer {
|
||||||
contract { callsInPlace(init) }
|
contract { callsInPlace(init) }
|
||||||
return LongBuffer(LongArray(size) { init(it) })
|
return LongBuffer(LongArray(size) { init(it) })
|
||||||
|
@ -140,7 +140,6 @@ interface MutableNDStructure<T> : NDStructure<T> {
|
|||||||
operator fun set(index: IntArray, value: T)
|
operator fun set(index: IntArray, value: T)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <T> MutableNDStructure<T>.mapInPlace(action: (IntArray, T) -> T) {
|
inline fun <T> MutableNDStructure<T>.mapInPlace(action: (IntArray, T) -> T) {
|
||||||
contract { callsInPlace(action) }
|
contract { callsInPlace(action) }
|
||||||
elements().forEach { (index, oldValue) -> this[index] = action(index, oldValue) }
|
elements().forEach { (index, oldValue) -> this[index] = action(index, oldValue) }
|
||||||
|
@ -30,7 +30,6 @@ inline class RealBuffer(val array: DoubleArray) : MutableBuffer<Double> {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an buffer element given its index.
|
* It should return the value for an buffer element given its index.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun RealBuffer(size: Int, init: (Int) -> Double): RealBuffer {
|
inline fun RealBuffer(size: Int, init: (Int) -> Double): RealBuffer {
|
||||||
contract { callsInPlace(init) }
|
contract { callsInPlace(init) }
|
||||||
return RealBuffer(DoubleArray(size) { init(it) })
|
return RealBuffer(DoubleArray(size) { init(it) })
|
||||||
|
@ -30,7 +30,6 @@ inline class ShortBuffer(val array: ShortArray) : MutableBuffer<Short> {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an buffer element given its index.
|
* It should return the value for an buffer element given its index.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun ShortBuffer(size: Int, init: (Int) -> Short): ShortBuffer {
|
inline fun ShortBuffer(size: Int, init: (Int) -> Short): ShortBuffer {
|
||||||
contract { callsInPlace(init) }
|
contract { callsInPlace(init) }
|
||||||
return ShortBuffer(ShortArray(size) { init(it) })
|
return ShortBuffer(ShortArray(size) { init(it) })
|
||||||
|
@ -4,20 +4,27 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kotlin.sourceSets {
|
kotlin.sourceSets {
|
||||||
|
all {
|
||||||
|
with(languageSettings) {
|
||||||
|
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
||||||
|
useExperimentalAnnotation("kotlinx.coroutines.InternalCoroutinesApi")
|
||||||
|
useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi")
|
||||||
|
useExperimentalAnnotation("kotlinx.coroutines.FlowPreview")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
commonMain {
|
commonMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
api(project(":kmath-core"))
|
api(project(":kmath-core"))
|
||||||
api("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Scientifik.coroutinesVersion}")
|
api("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Scientifik.coroutinesVersion}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jvmMain {
|
jvmMain {
|
||||||
dependencies {
|
dependencies { api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Scientifik.coroutinesVersion}") }
|
||||||
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Scientifik.coroutinesVersion}")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jsMain {
|
jsMain {
|
||||||
dependencies {
|
dependencies { api("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:${Scientifik.coroutinesVersion}") }
|
||||||
api("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:${Scientifik.coroutinesVersion}")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package scientifik.kmath.chains
|
package scientifik.kmath.chains
|
||||||
|
|
||||||
import kotlinx.coroutines.InternalCoroutinesApi
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.FlowCollector
|
import kotlinx.coroutines.flow.FlowCollector
|
||||||
|
import kotlinx.coroutines.flow.flow
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import kotlinx.coroutines.sync.withLock
|
import kotlinx.coroutines.sync.withLock
|
||||||
|
|
||||||
@ -37,14 +37,8 @@ interface Chain<out R> : Flow<R> {
|
|||||||
*/
|
*/
|
||||||
fun fork(): Chain<R>
|
fun fork(): Chain<R>
|
||||||
|
|
||||||
@OptIn(InternalCoroutinesApi::class)
|
override suspend fun collect(collector: FlowCollector<R>): Unit =
|
||||||
override suspend fun collect(collector: FlowCollector<R>) {
|
flow { while (true) emit(next()) }.collect(collector)
|
||||||
kotlinx.coroutines.flow.flow {
|
|
||||||
while (true) {
|
|
||||||
emit(next())
|
|
||||||
}
|
|
||||||
}.collect(collector)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object
|
companion object
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import scientifik.kmath.operations.Space
|
|||||||
import scientifik.kmath.operations.SpaceOperations
|
import scientifik.kmath.operations.SpaceOperations
|
||||||
import scientifik.kmath.operations.invoke
|
import scientifik.kmath.operations.invoke
|
||||||
|
|
||||||
|
|
||||||
@ExperimentalCoroutinesApi
|
@ExperimentalCoroutinesApi
|
||||||
fun <T> Flow<T>.cumulativeSum(space: SpaceOperations<T>): Flow<T> = space {
|
fun <T> Flow<T>.cumulativeSum(space: SpaceOperations<T>): Flow<T> = space {
|
||||||
scanReduce { sum: T, element: T -> sum + element }
|
scanReduce { sum: T, element: T -> sum + element }
|
||||||
|
@ -3,7 +3,6 @@ package scientifik.kmath.coroutines
|
|||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.channels.produce
|
import kotlinx.coroutines.channels.produce
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
||||||
import kotlin.contracts.ExperimentalContracts
|
|
||||||
import kotlin.contracts.contract
|
import kotlin.contracts.contract
|
||||||
|
|
||||||
val Dispatchers.Math: CoroutineDispatcher
|
val Dispatchers.Math: CoroutineDispatcher
|
||||||
@ -25,15 +24,11 @@ internal class LazyDeferred<T>(val dispatcher: CoroutineDispatcher, val block: s
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AsyncFlow<T> internal constructor(internal val deferredFlow: Flow<LazyDeferred<T>>) : Flow<T> {
|
class AsyncFlow<T> internal constructor(internal val deferredFlow: Flow<LazyDeferred<T>>) : Flow<T> {
|
||||||
@InternalCoroutinesApi
|
|
||||||
override suspend fun collect(collector: FlowCollector<T>) {
|
override suspend fun collect(collector: FlowCollector<T>) {
|
||||||
deferredFlow.collect {
|
deferredFlow.collect { collector.emit((it.await())) }
|
||||||
collector.emit((it.await()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FlowPreview
|
|
||||||
fun <T, R> Flow<T>.async(
|
fun <T, R> Flow<T>.async(
|
||||||
dispatcher: CoroutineDispatcher = Dispatchers.Default,
|
dispatcher: CoroutineDispatcher = Dispatchers.Default,
|
||||||
block: suspend CoroutineScope.(T) -> R
|
block: suspend CoroutineScope.(T) -> R
|
||||||
@ -44,7 +39,6 @@ fun <T, R> Flow<T>.async(
|
|||||||
return AsyncFlow(flow)
|
return AsyncFlow(flow)
|
||||||
}
|
}
|
||||||
|
|
||||||
@FlowPreview
|
|
||||||
fun <T, R> AsyncFlow<T>.map(action: (T) -> R): AsyncFlow<R> =
|
fun <T, R> AsyncFlow<T>.map(action: (T) -> R): AsyncFlow<R> =
|
||||||
AsyncFlow(deferredFlow.map { input ->
|
AsyncFlow(deferredFlow.map { input ->
|
||||||
//TODO add function composition
|
//TODO add function composition
|
||||||
@ -54,10 +48,9 @@ fun <T, R> AsyncFlow<T>.map(action: (T) -> R): AsyncFlow<R> =
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ExperimentalCoroutinesApi
|
|
||||||
@FlowPreview
|
|
||||||
suspend fun <T> AsyncFlow<T>.collect(concurrency: Int, collector: FlowCollector<T>) {
|
suspend fun <T> AsyncFlow<T>.collect(concurrency: Int, collector: FlowCollector<T>) {
|
||||||
require(concurrency >= 1) { "Buffer size should be more than 1, but was $concurrency" }
|
require(concurrency >= 1) { "Buffer size should be more than 1, but was $concurrency" }
|
||||||
|
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
//Starting up to N deferred coroutines ahead of time
|
//Starting up to N deferred coroutines ahead of time
|
||||||
val channel = produce(capacity = concurrency - 1) {
|
val channel = produce(capacity = concurrency - 1) {
|
||||||
@ -83,9 +76,6 @@ suspend fun <T> AsyncFlow<T>.collect(concurrency: Int, collector: FlowCollector<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
@ExperimentalCoroutinesApi
|
|
||||||
@FlowPreview
|
|
||||||
suspend inline fun <T> AsyncFlow<T>.collect(concurrency: Int, crossinline action: suspend (value: T) -> Unit) {
|
suspend inline fun <T> AsyncFlow<T>.collect(concurrency: Int, crossinline action: suspend (value: T) -> Unit) {
|
||||||
contract { callsInPlace(action) }
|
contract { callsInPlace(action) }
|
||||||
|
|
||||||
@ -94,9 +84,6 @@ suspend inline fun <T> AsyncFlow<T>.collect(concurrency: Int, crossinline action
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
@ExperimentalCoroutinesApi
|
|
||||||
@FlowPreview
|
|
||||||
inline fun <T, R> Flow<T>.mapParallel(
|
inline fun <T, R> Flow<T>.mapParallel(
|
||||||
dispatcher: CoroutineDispatcher = Dispatchers.Default,
|
dispatcher: CoroutineDispatcher = Dispatchers.Default,
|
||||||
crossinline transform: suspend (T) -> R
|
crossinline transform: suspend (T) -> R
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
plugins {
|
plugins { id("scientifik.mpp") }
|
||||||
id("scientifik.mpp")
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin.sourceSets {
|
kotlin.sourceSets {
|
||||||
commonMain {
|
all { languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts") }
|
||||||
dependencies {
|
commonMain { dependencies { api(project(":kmath-core")) } }
|
||||||
api(project(":kmath-core"))
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -120,7 +120,6 @@ operator fun Matrix<Double>.minus(other: Matrix<Double>): RealMatrix =
|
|||||||
* Operations on columns
|
* Operations on columns
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun Matrix<Double>.appendColumn(crossinline mapper: (Buffer<Double>) -> Double): Matrix<Double> {
|
inline fun Matrix<Double>.appendColumn(crossinline mapper: (Buffer<Double>) -> Double): Matrix<Double> {
|
||||||
contract { callsInPlace(mapper) }
|
contract { callsInPlace(mapper) }
|
||||||
|
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
plugins {
|
plugins { id("scientifik.mpp") }
|
||||||
id("scientifik.mpp")
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin.sourceSets {
|
kotlin.sourceSets {
|
||||||
commonMain {
|
all { languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts") }
|
||||||
dependencies {
|
commonMain { dependencies { api(project(":kmath-core")) } }
|
||||||
api(project(":kmath-core"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,6 @@ class PolynomialSpace<T : Any, C : Ring<T>>(val ring: C) : Space<Polynomial<T>>
|
|||||||
operator fun Polynomial<T>.invoke(arg: T): T = value(ring, arg)
|
operator fun Polynomial<T>.invoke(arg: T): T = value(ring, arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun <T : Any, C : Ring<T>, R> C.polynomial(block: PolynomialSpace<T, C>.() -> R): R {
|
inline fun <T : Any, C : Ring<T>, R> C.polynomial(block: PolynomialSpace<T, C>.() -> R): R {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
return PolynomialSpace(this).block()
|
return PolynomialSpace(this).block()
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
plugins {
|
plugins { id("scientifik.mpp") }
|
||||||
id("scientifik.mpp")
|
kotlin.sourceSets.all { languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts") }
|
||||||
}
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package scientifik.memory
|
package scientifik.memory
|
||||||
|
|
||||||
import kotlin.contracts.ExperimentalContracts
|
|
||||||
import kotlin.contracts.InvocationKind
|
import kotlin.contracts.InvocationKind
|
||||||
import kotlin.contracts.contract
|
import kotlin.contracts.contract
|
||||||
|
|
||||||
@ -84,7 +83,6 @@ interface MemoryReader {
|
|||||||
/**
|
/**
|
||||||
* Uses the memory for read then releases the reader.
|
* Uses the memory for read then releases the reader.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun Memory.read(block: MemoryReader.() -> Unit) {
|
inline fun Memory.read(block: MemoryReader.() -> Unit) {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
reader().apply(block).release()
|
reader().apply(block).release()
|
||||||
@ -138,7 +136,6 @@ interface MemoryWriter {
|
|||||||
/**
|
/**
|
||||||
* Uses the memory for write then releases the writer.
|
* Uses the memory for write then releases the writer.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
inline fun Memory.write(block: MemoryWriter.() -> Unit) {
|
inline fun Memory.write(block: MemoryWriter.() -> Unit) {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
writer().apply(block).release()
|
writer().apply(block).release()
|
||||||
|
@ -117,7 +117,6 @@ fun ByteBuffer.asMemory(startOffset: Int = 0, size: Int = limit()): Memory =
|
|||||||
/**
|
/**
|
||||||
* Uses direct memory-mapped buffer from file to read something and close it afterwards.
|
* Uses direct memory-mapped buffer from file to read something and close it afterwards.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
inline fun <R> Path.readAsMemory(position: Long = 0, size: Long = Files.size(this), block: Memory.() -> R): R {
|
inline fun <R> Path.readAsMemory(position: Long = 0, size: Long = Files.size(this), block: Memory.() -> R): R {
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
|
Loading…
Reference in New Issue
Block a user