Compare commits

..

No commits in common. "82196250f651d0ba82eb89a1ac3b008b2af184a1" and "203a350650de23b987d58fe11eadc578a0f2acc8" have entirely different histories.

4 changed files with 7 additions and 18 deletions

View File

@ -9,7 +9,8 @@ kscience {
wasm() wasm()
dependencies { dependencies {
api(projects.kmathCore) api(project(":kmath-core"))
api(project(":kmath-complex"))
api(spclibs.kotlinx.coroutines.core) api(spclibs.kotlinx.coroutines.core)
} }
} }

View File

@ -23,8 +23,6 @@ public class RingBuffer<T>(
private val mutex: Mutex = Mutex() private val mutex: Mutex = Mutex()
public val capacity: Int get() = buffer.size
override var size: Int = size override var size: Int = size
private set private set
@ -34,7 +32,7 @@ public class RingBuffer<T>(
return buffer[startIndex.forward(index)] return buffer[startIndex.forward(index)]
} }
public fun isFull(): Boolean = size == capacity public fun isFull(): Boolean = size == buffer.size
/** /**
* Iterator could provide wrong results if buffer is changed in initialization (iteration is safe) * Iterator could provide wrong results if buffer is changed in initialization (iteration is safe)
@ -61,9 +59,6 @@ public class RingBuffer<T>(
VirtualBuffer(size) { i -> copy[startIndex.forward(i)] } VirtualBuffer(size) { i -> copy[startIndex.forward(i)] }
} }
/**
* Add an element to the end of the [RingBuffer]. If buffer capacity is reached, the first element is automatically removed.
*/
public suspend fun push(element: T) { public suspend fun push(element: T) {
mutex.withLock { mutex.withLock {
buffer[startIndex.forward(size)] = element buffer[startIndex.forward(size)] = element
@ -71,15 +66,7 @@ public class RingBuffer<T>(
} }
} }
/** private fun Int.forward(n: Int): Int = (this + n) % (buffer.size)
* Reset buffer to its empty state
*/
public suspend fun reset(): Unit = mutex.withLock {
startIndex = 0
size = 0
}
private fun Int.forward(n: Int): Int = (this + n) % capacity
override fun toString(): String = Buffer.toString(this) override fun toString(): String = Buffer.toString(this)
} }

View File

@ -15,7 +15,7 @@ kotlin{
sourceSets{ sourceSets{
commonMain{ commonMain{
dependencies{ dependencies{
api(projects.kmathTensors) api(project(":kmath-tensors"))
api("org.jetbrains.kotlinx:multik-core:$multikVersion") api("org.jetbrains.kotlinx:multik-core:$multikVersion")
} }
} }

View File

@ -9,6 +9,7 @@ import org.jetbrains.kotlinx.multik.ndarray.data.*
import space.kscience.attributes.SafeType import space.kscience.attributes.SafeType
import space.kscience.attributes.safeTypeOf import space.kscience.attributes.safeTypeOf
import space.kscience.kmath.PerformancePitfall import space.kscience.kmath.PerformancePitfall
import space.kscience.kmath.complex.ComplexField
import space.kscience.kmath.nd.ShapeND import space.kscience.kmath.nd.ShapeND
import space.kscience.kmath.operations.* import space.kscience.kmath.operations.*
import space.kscience.kmath.tensors.api.Tensor import space.kscience.kmath.tensors.api.Tensor
@ -23,7 +24,7 @@ public val DataType.type: SafeType<*>
DataType.FloatDataType -> Float32Field.type DataType.FloatDataType -> Float32Field.type
DataType.DoubleDataType -> Float64Field.type DataType.DoubleDataType -> Float64Field.type
DataType.ComplexFloatDataType -> safeTypeOf<Pair<Float, Float>>() DataType.ComplexFloatDataType -> safeTypeOf<Pair<Float, Float>>()
DataType.ComplexDoubleDataType -> safeTypeOf<Pair<Double, Double>>() DataType.ComplexDoubleDataType -> ComplexField.type
} }