forked from kscience/kmath
Changed tests
This commit is contained in:
parent
455c9d188d
commit
1773b49b1f
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018-2023 KMath contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package space.kscience.kmath.structures
|
||||
|
||||
import space.kscience.kmath.operations.DoubleField
|
||||
import space.kscience.kmath.operations.buffer
|
||||
import space.kscience.kmath.operations.bufferAlgebra
|
||||
import space.kscience.kmath.operations.withSize
|
||||
|
||||
//inline fun <reified R : Any> MutableBuffer.Companion.same(
|
||||
// n: Int,
|
||||
// value: R
|
||||
//): MutableBuffer<R> = auto(n) { value }
|
||||
|
||||
|
||||
fun main() {
|
||||
with(DoubleField.bufferAlgebra.withSize(5)) {
|
||||
println(number(2.0) + buffer(1, 2, 10, 4, 9))
|
||||
}
|
||||
}
|
@ -6,33 +6,31 @@
|
||||
package space.kscience.kmath.series
|
||||
|
||||
import space.kscience.kmath.nd.*
|
||||
import space.kscience.kmath.operations.DoubleField
|
||||
import space.kscience.kmath.operations.algebra
|
||||
import space.kscience.kmath.operations.bufferAlgebra
|
||||
import space.kscience.kmath.structures.DoubleBuffer
|
||||
import space.kscience.kmath.structures.asBuffer
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
|
||||
class DTWTest {
|
||||
|
||||
@Test
|
||||
fun someData() : Unit {
|
||||
with(Double.algebra.bufferAlgebra) {
|
||||
with(Double.algebra.bufferAlgebra.seriesAlgebra()) {
|
||||
val firstSequence: DoubleArray = doubleArrayOf(0.0, 2.0, 3.0, 1.0, 3.0, 0.1, 0.0, 1.0)
|
||||
val secondSequence: DoubleArray = doubleArrayOf(1.0, 0.0, 3.0, 0.0, 0.0, 3.0, 2.0, 0.0, 2.0)
|
||||
|
||||
val seriesOne: DoubleBuffer = firstSequence.asBuffer()
|
||||
val seriesTwo: DoubleBuffer = secondSequence.asBuffer()
|
||||
val seriesOne: Series<Double> = firstSequence.asBuffer().moveTo(0)
|
||||
val seriesTwo: Series<Double> = secondSequence.asBuffer().moveTo(0)
|
||||
|
||||
val result = dynamicTimeWarping(seriesOne, seriesTwo)
|
||||
val result = DoubleFieldOpsND.dynamicTimeWarping(seriesOne, seriesTwo)
|
||||
println("Total penalty coefficient: ${result.totalCost}")
|
||||
print("Alignment: ")
|
||||
println(result.alignMatrix)
|
||||
for ((i , j) in result.alignMatrix.indices) {
|
||||
if (result.alignMatrix[i, j] == 1) {
|
||||
print("[$i, $j] ")
|
||||
}
|
||||
if (result.alignMatrix[i, j] > 0.0) {
|
||||
print("[$i, $j] ")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user