KMP library for tensors #300
@ -1882,6 +1882,15 @@ public final class space/kscience/kmath/structures/MutableBuffer$Companion {
|
|||||||
public final fun short-1yRgbGw (ILkotlin/jvm/functions/Function1;)[S
|
public final fun short-1yRgbGw (ILkotlin/jvm/functions/Function1;)[S
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class space/kscience/kmath/structures/MutableBufferFromGenerator : space/kscience/kmath/structures/MutableBuffer {
|
||||||
|
public fun <init> (ILkotlin/jvm/functions/Function1;)V
|
||||||
|
public fun copy ()Lspace/kscience/kmath/structures/MutableBuffer;
|
||||||
|
public fun get (I)Ljava/lang/Object;
|
||||||
|
public fun getSize ()I
|
||||||
|
public fun iterator ()Ljava/util/Iterator;
|
||||||
|
public fun set (ILjava/lang/Object;)V
|
||||||
|
}
|
||||||
|
|
||||||
public final class space/kscience/kmath/structures/MutableListBuffer : space/kscience/kmath/structures/MutableBuffer {
|
public final class space/kscience/kmath/structures/MutableListBuffer : space/kscience/kmath/structures/MutableBuffer {
|
||||||
public static final synthetic fun box-impl (Ljava/util/List;)Lspace/kscience/kmath/structures/MutableListBuffer;
|
public static final synthetic fun box-impl (Ljava/util/List;)Lspace/kscience/kmath/structures/MutableListBuffer;
|
||||||
public static fun constructor-impl (ILkotlin/jvm/functions/Function1;)Ljava/util/List;
|
public static fun constructor-impl (ILkotlin/jvm/functions/Function1;)Ljava/util/List;
|
||||||
@ -1990,12 +1999,3 @@ public final class space/kscience/kmath/structures/VirtualBuffer : space/kscienc
|
|||||||
public fun iterator ()Ljava/util/Iterator;
|
public fun iterator ()Ljava/util/Iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class space/kscience/kmath/structures/VirtualMutableBuffer : space/kscience/kmath/structures/MutableBuffer {
|
|
||||||
public fun <init> (ILkotlin/jvm/functions/Function1;)V
|
|
||||||
public fun copy ()Lspace/kscience/kmath/structures/MutableBuffer;
|
|
||||||
public fun get (I)Ljava/lang/Object;
|
|
||||||
public fun getSize ()I
|
|
||||||
public fun iterator ()Ljava/util/Iterator;
|
|
||||||
public fun set (ILjava/lang/Object;)V
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ private value class Structure1DWrapper<T>(val structure: StructureND<T>) : Struc
|
|||||||
/**
|
/**
|
||||||
* A 1D wrapper for a mutable nd-structure
|
* A 1D wrapper for a mutable nd-structure
|
||||||
*/
|
*/
|
||||||
private inline class MutableStructure1DWrapper<T>(val structure: MutableStructureND<T>) : MutableStructure1D<T> {
|
private class MutableStructure1DWrapper<T>(val structure: MutableStructureND<T>) : MutableStructure1D<T> {
|
||||||
override val shape: IntArray get() = structure.shape
|
override val shape: IntArray get() = structure.shape
|
||||||
override val size: Int get() = structure.shape[0]
|
override val size: Int get() = structure.shape[0]
|
||||||
override fun elements(): Sequence<Pair<IntArray, T>> = structure.elements()
|
override fun elements(): Sequence<Pair<IntArray, T>> = structure.elements()
|
||||||
@ -81,7 +81,7 @@ private value class Buffer1DWrapper<T>(val buffer: Buffer<T>) : Structure1D<T> {
|
|||||||
override operator fun get(index: Int): T = buffer[index]
|
override operator fun get(index: Int): T = buffer[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
internal inline class MutableBuffer1DWrapper<T>(val buffer: MutableBuffer<T>) : MutableStructure1D<T> {
|
internal class MutableBuffer1DWrapper<T>(val buffer: MutableBuffer<T>) : MutableStructure1D<T> {
|
||||||
override val shape: IntArray get() = intArrayOf(buffer.size)
|
override val shape: IntArray get() = intArrayOf(buffer.size)
|
||||||
override val size: Int get() = buffer.size
|
override val size: Int get() = buffer.size
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ package space.kscience.kmath.nd
|
|||||||
import space.kscience.kmath.misc.UnstableKMathAPI
|
import space.kscience.kmath.misc.UnstableKMathAPI
|
||||||
import space.kscience.kmath.structures.Buffer
|
import space.kscience.kmath.structures.Buffer
|
||||||
import space.kscience.kmath.structures.VirtualBuffer
|
import space.kscience.kmath.structures.VirtualBuffer
|
||||||
import space.kscience.kmath.structures.VirtualMutableBuffer
|
import space.kscience.kmath.structures.MutableBufferFromGenerator
|
||||||
import kotlin.jvm.JvmInline
|
import kotlin.jvm.JvmInline
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
@ -81,13 +81,13 @@ public interface MutableStructure2D<T> : Structure2D<T>, MutableStructureND<T> {
|
|||||||
* The buffer of rows of this structure. It gets elements from the structure dynamically.
|
* The buffer of rows of this structure. It gets elements from the structure dynamically.
|
||||||
*/
|
*/
|
||||||
override val rows: List<MutableStructure1D<T>>
|
override val rows: List<MutableStructure1D<T>>
|
||||||
get() = List(rowNum) { i -> MutableBuffer1DWrapper(VirtualMutableBuffer(colNum) { j -> get(i, j) })}
|
get() = List(rowNum) { i -> MutableBuffer1DWrapper(MutableBufferFromGenerator(colNum) { j -> get(i, j) })}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The buffer of columns of this structure. It gets elements from the structure dynamically.
|
* The buffer of columns of this structure. It gets elements from the structure dynamically.
|
||||||
*/
|
*/
|
||||||
override val columns: List<MutableStructure1D<T>>
|
override val columns: List<MutableStructure1D<T>>
|
||||||
get() = List(colNum) { j -> MutableBuffer1DWrapper(VirtualMutableBuffer(rowNum) { i -> get(i, j) }) }
|
get() = List(colNum) { j -> MutableBuffer1DWrapper(MutableBufferFromGenerator(rowNum) { i -> get(i, j) }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -292,7 +292,7 @@ public class VirtualBuffer<T>(override val size: Int, private val generator: (In
|
|||||||
override operator fun iterator(): Iterator<T> = (0 until size).asSequence().map(generator).iterator()
|
override operator fun iterator(): Iterator<T> = (0 until size).asSequence().map(generator).iterator()
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VirtualMutableBuffer<T>(override val size: Int, private val generator: (Int) -> T) : MutableBuffer<T> {
|
public class MutableBufferFromGenerator<T>(override val size: Int, private val generator: (Int) -> T) : MutableBuffer<T> {
|
||||||
|
|
||||||
private val bufferHolder: MutableListBuffer<T> = (0 until size).map(generator).toMutableList().asMutableBuffer()
|
private val bufferHolder: MutableListBuffer<T> = (0 until size).map(generator).toMutableList().asMutableBuffer()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user