forked from kscience/kmath
Cleanup
This commit is contained in:
parent
209e17cd42
commit
6581f3dd8a
@ -4,7 +4,7 @@ plugins {
|
||||
id("ru.mipt.npm.project")
|
||||
}
|
||||
|
||||
internal val kmathVersion: String by extra("0.2.0-dev-7")
|
||||
internal val kmathVersion: String by extra("0.2.0")
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
|
@ -69,6 +69,14 @@ benchmark {
|
||||
targets.register("benchmarks")
|
||||
// This one matches sourceSet name above
|
||||
|
||||
configurations.register("buffer") {
|
||||
warmups = 1 // number of warmup iterations
|
||||
iterations = 3 // number of iterations
|
||||
iterationTime = 500 // time in seconds per iteration
|
||||
iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds
|
||||
include("BufferBenchmark")
|
||||
}
|
||||
|
||||
configurations.register("dot") {
|
||||
warmups = 1 // number of warmup iterations
|
||||
iterations = 3 // number of iterations
|
||||
|
@ -4,6 +4,7 @@ import space.kscience.kmath.nd.DefaultStrides
|
||||
import space.kscience.kmath.nd.NDBuffer
|
||||
import kotlin.system.measureTimeMillis
|
||||
|
||||
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
|
||||
fun main() {
|
||||
val n = 6000
|
||||
val array = DoubleArray(n * n) { 1.0 }
|
||||
|
@ -4,6 +4,7 @@ import space.kscience.kmath.nd.NDStructure
|
||||
import space.kscience.kmath.nd.mapToBuffer
|
||||
import kotlin.system.measureTimeMillis
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
fun main() {
|
||||
val n = 6000
|
||||
val structure = NDStructure.build(intArrayOf(n, n), Buffer.Companion::auto) { 1.0 }
|
||||
|
@ -3,6 +3,7 @@ package space.kscience.kmath.complex
|
||||
import space.kscience.kmath.memory.MemoryReader
|
||||
import space.kscience.kmath.memory.MemorySpec
|
||||
import space.kscience.kmath.memory.MemoryWriter
|
||||
import space.kscience.kmath.misc.UnstableKMathAPI
|
||||
import space.kscience.kmath.operations.ExtendedField
|
||||
import space.kscience.kmath.operations.FieldElement
|
||||
import space.kscience.kmath.operations.Norm
|
||||
@ -45,6 +46,7 @@ private val PI_DIV_2 = Complex(PI / 2, 0)
|
||||
/**
|
||||
* A field of [Complex].
|
||||
*/
|
||||
@OptIn(UnstableKMathAPI::class)
|
||||
public object ComplexField : ExtendedField<Complex>, Norm<Complex, Complex>, RingWithNumbers<Complex> {
|
||||
public override val zero: Complex = 0.0.toComplex()
|
||||
public override val one: Complex = 1.0.toComplex()
|
||||
@ -166,6 +168,7 @@ public object ComplexField : ExtendedField<Complex>, Norm<Complex, Complex>, Rin
|
||||
* @property re The real part.
|
||||
* @property im The imaginary part.
|
||||
*/
|
||||
@OptIn(UnstableKMathAPI::class)
|
||||
public data class Complex(val re: Double, val im: Double) : FieldElement<Complex, ComplexField> {
|
||||
public constructor(re: Number, im: Number) : this(re.toDouble(), im.toDouble())
|
||||
public constructor(re: Number) : this(re.toDouble(), 0.0)
|
||||
|
@ -3,6 +3,7 @@ package space.kscience.kmath.complex
|
||||
import space.kscience.kmath.memory.MemoryReader
|
||||
import space.kscience.kmath.memory.MemorySpec
|
||||
import space.kscience.kmath.memory.MemoryWriter
|
||||
import space.kscience.kmath.misc.UnstableKMathAPI
|
||||
import space.kscience.kmath.operations.*
|
||||
import space.kscience.kmath.structures.Buffer
|
||||
import space.kscience.kmath.structures.MemoryBuffer
|
||||
@ -34,6 +35,7 @@ public val Quaternion.r: Double
|
||||
/**
|
||||
* A field of [Quaternion].
|
||||
*/
|
||||
@OptIn(UnstableKMathAPI::class)
|
||||
public object QuaternionField : Field<Quaternion>, Norm<Quaternion, Quaternion>, PowerOperations<Quaternion>,
|
||||
ExponentialOperations<Quaternion>, RingWithNumbers<Quaternion> {
|
||||
override val zero: Quaternion = 0.toQuaternion()
|
||||
|
@ -91,7 +91,7 @@ public class BufferMatrixContext<T : Any, R : Ring<T>>(
|
||||
public class BufferMatrix<T : Any>(
|
||||
public override val rowNum: Int,
|
||||
public override val colNum: Int,
|
||||
public val buffer: Buffer<out T>,
|
||||
public val buffer: Buffer<T>,
|
||||
) : Matrix<T> {
|
||||
|
||||
init {
|
||||
|
@ -9,9 +9,9 @@ package space.kscience.kmath.structures
|
||||
public inline class RealBuffer(public val array: DoubleArray) : MutableBuffer<Double> {
|
||||
override val size: Int get() = array.size
|
||||
|
||||
override inline operator fun get(index: Int): Double = array[index]
|
||||
override operator fun get(index: Int): Double = array[index]
|
||||
|
||||
override inline operator fun set(index: Int, value: Double) {
|
||||
override operator fun set(index: Int, value: Double) {
|
||||
array[index] = value
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ public fun <T> Buffer<T>.asFlow(): Flow<T> = iterator().asFlow()
|
||||
* Flat map a [Flow] of [Buffer] into continuous [Flow] of elements
|
||||
*/
|
||||
@FlowPreview
|
||||
public fun <T> Flow<Buffer<out T>>.spread(): Flow<T> = flatMapConcat { it.asFlow() }
|
||||
public fun <T> Flow<Buffer<T>>.spread(): Flow<T> = flatMapConcat { it.asFlow() }
|
||||
|
||||
/**
|
||||
* Collect incoming flow into fixed size chunks
|
||||
|
@ -28,7 +28,7 @@ internal class RingBufferTest {
|
||||
val windowed = flow.windowed(10)
|
||||
|
||||
runBlocking {
|
||||
val first = windowed.take(1).single()
|
||||
@Suppress("UNUSED_VARIABLE") val first = windowed.take(1).single()
|
||||
val res = windowed.take(15).map { it.asSequence().average() }.toList()
|
||||
assertEquals(0.0, res[0])
|
||||
assertEquals(4.5, res[9])
|
||||
|
@ -13,7 +13,7 @@ public infix fun BufferMatrix<Double>.dot(other: BufferMatrix<Double>): BufferMa
|
||||
val resultArray = DoubleArray(this.rowNum * other.colNum)
|
||||
|
||||
//convert to array to insure there is no memory indirection
|
||||
fun Buffer<out Double>.unsafeArray() = if (this is RealBuffer)
|
||||
fun Buffer<Double>.unsafeArray() = if (this is RealBuffer)
|
||||
this.array
|
||||
else
|
||||
DoubleArray(size) { get(it) }
|
||||
|
@ -70,7 +70,7 @@ public class RealHistogramSpace(
|
||||
val ndCounter = NDStructure.auto(strides) { Counter.real() }
|
||||
val hBuilder = HistogramBuilder<Double> { point, value ->
|
||||
val index = getIndex(point)
|
||||
ndCounter[index].add(1.0)
|
||||
ndCounter[index].add(value.toDouble())
|
||||
}
|
||||
hBuilder.apply(builder)
|
||||
val values: NDBuffer<Double> = ndCounter.mapToBuffer { it.value }
|
||||
|
@ -2,13 +2,12 @@ pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
jcenter()
|
||||
maven("https://repo.kotlin.link")
|
||||
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
||||
maven("https://dl.bintray.com/mipt-npm/kscience")
|
||||
maven("https://dl.bintray.com/mipt-npm/dev")
|
||||
maven("https://dl.bintray.com/kotlin/kotlinx")
|
||||
}
|
||||
|
||||
val toolsVersion = "0.7.6"
|
||||
val toolsVersion = "0.7.7"
|
||||
val kotlinVersion = "1.4.30"
|
||||
|
||||
plugins {
|
||||
|
Loading…
Reference in New Issue
Block a user