diff --git a/examples/src/main/kotlin/space/kscience/kmath/series/analyzeDif.kt b/examples/src/main/kotlin/space/kscience/kmath/series/analyzeDif.kt index d67d59bfc..9b7493438 100644 --- a/examples/src/main/kotlin/space/kscience/kmath/series/analyzeDif.kt +++ b/examples/src/main/kotlin/space/kscience/kmath/series/analyzeDif.kt @@ -6,6 +6,7 @@ import kotlinx.html.h1 import space.kscience.kmath.operations.algebra import space.kscience.kmath.operations.bufferAlgebra import space.kscience.kmath.structures.Buffer +import space.kscience.kmath.structures.slice import space.kscience.kmath.structures.toList import space.kscience.plotly.* import kotlin.math.PI @@ -28,7 +29,7 @@ fun main() = with(Double.algebra.bufferAlgebra.seriesAlgebra()) { val s1 = series(100) { sin(2 * PI * it / 100) + 1.0 } - val s2 = s1.slice(20..50).moveTo(40) + val s2 = s1.slice(20U..50U).moveTo(40) val s3: Buffer = s1.zip(s2) { l, r -> l + r } //s1 + s2 val s4 = ln(s3) diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/BufferView.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/BufferView.kt index d4e6a4a58..d82efa865 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/BufferView.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/BufferView.kt @@ -137,4 +137,4 @@ public class PermutatedBuffer( /** * Created a permuted view of given buffer using provided [indices] */ -public fun Buffer.view(indices: IntArray): PermutatedBuffer = PermutatedBuffer(this, indices) \ No newline at end of file +public fun Buffer.permute(indices: IntArray): PermutatedBuffer = PermutatedBuffer(this, indices) \ No newline at end of file diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/SeriesAlgebra.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/SeriesAlgebra.kt index ae1bfe0e7..de72c7346 100644 --- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/SeriesAlgebra.kt +++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/SeriesAlgebra.kt @@ -14,14 +14,14 @@ internal fun IntRange.intersect(other: IntRange): IntRange = max(first, other.first)..min(last, other.last) @PublishedApi -internal val IntRange.size +internal val IntRange.size: Int get() = last - first + 1 @PublishedApi internal operator fun IntRange.contains(other: IntRange): Boolean = (other.first in this) && (other.last in this) -//TODO add permutated buffer -//TODO add rank function +//TODO add permutation sort +//TODO check rank statistics public interface Series : Buffer { @@ -90,24 +90,6 @@ public class SeriesAlgebra, out BA : BufferAlgebra, L>( OffsetBufer(this, index, size) } - /** - * Create a buffer view using given absolute range - */ - public fun Buffer.slice(range: IntRange): Series { - val size = range.size - return if (this is Series) { - OffsetBufer(this, indices.first + range.first, size) - } else { - OffsetBufer(this, range.first, size) - } - } - - public fun Buffer.expand(range: IntRange, defaultValue: T): Series = if (range in indices) { - slice(range) - } else { - TODO() - } - public val Buffer.offset: Int get() = if (this is Series) position else 0 /**