Package space.kscience.kmath.chains

Types

BlockingBufferChain
Link copied to clipboard
common
interface BlockingBufferChain<out T> : BlockingChain<T> , BufferChain<T>
BlockingChain
Link copied to clipboard
common
interface BlockingChain<out T> : Chain<T>
A chain with blocking generator that could be used without suspension
BlockingDoubleChain
Link copied to clipboard
common
interface BlockingDoubleChain : BlockingBufferChain<Double>
Chunked, specialized chain for double values, which supports blocking nextBlocking operation
BlockingIntChain
Link copied to clipboard
common
interface BlockingIntChain : BlockingBufferChain<Int>
Performance optimized chain for integer values
BufferChain
Link copied to clipboard
common
interface BufferChain<out T> : Chain<T>
Chain
Link copied to clipboard
common
interface Chain<out T> : Flow<T>
A not-necessary-Markov chain of some type
ConstantChain
Link copied to clipboard
common
class ConstantChain<out T>(value: T) : Chain<T>
A chain that repeats the same value
MarkovChain
Link copied to clipboard
common
class MarkovChain<out R : Any>(seed: suspend () -> R, gen: suspend (R) -> R) : Chain<R>
A stateless Markov chain
SimpleChain
Link copied to clipboard
common
class SimpleChain<out R>(gen: suspend () -> R) : Chain<R>
A simple chain of independent tokens.
StatefulChain
Link copied to clipboard
common
class StatefulChain<S, out R>(state: S, seed: S.() -> R, forkState: (S) -> S, gen: suspend S.(R) -> R) : Chain<R>
A chain with possibly mutable state.

Functions

asChain
Link copied to clipboard
common
fun <T> Iterator<T>.asChain(): Chain<T>
fun <T> Sequence<T>.asChain(): Chain<T>
asSequence
Link copied to clipboard
fun <R> Chain<R>.asSequence(): Sequence<R>
Represent a chain as a sequence
collect
Link copied to clipboard
common
fun <T, R> Chain<T>.collect(mapper: suspend (Chain<T>) -> R): Chain<R>
Map the whole chain
collectWithState
Link copied to clipboard
common
fun <T, S, R> Chain<T>.collectWithState(state: S, stateFork: (S) -> S, mapper: suspend S.(Chain<T>) -> R): Chain<R>
cumulativeSum
Link copied to clipboard
common
fun <T> Flow<T>.cumulativeSum(group: GroupOps<T>): Flow<T>
filter
Link copied to clipboard
common
fun <T> Chain<T>.filter(block: (T) -> Boolean): Chain<T>
block must be a pure function or at least not use external random variables, otherwise fork could be broken
iterator
Link copied to clipboard
operator fun <R> Chain<R>.iterator(): Iterator<R>
Represent a chain as regular iterator (uses blocking calls)
map
Link copied to clipboard
common
fun BlockingDoubleChain.map(transform: (Double) -> Double): BlockingDoubleChain
fun <T, R> Chain<T>.map(func: suspend (T) -> R): Chain<R>
Map the chain result using suspended transformation.
mean
Link copied to clipboard
common
fun <T, S : Ring<T>, ScaleOperations<T>> Flow<T>.mean(space: S): Flow<T>
nextBuffer
Link copied to clipboard
common
inline suspend fun <T : Any> Chain<T>.nextBuffer(size: Int): Buffer<T>
nextBufferBlocking
Link copied to clipboard
common
inline fun <T : Any> BlockingChain<T>.nextBufferBlocking(size: Int): Buffer<T>
zip
Link copied to clipboard
common
fun <T, U, R> Chain<T>.zip(other: Chain<U>, block: suspend (T, U) -> R): Chain<R>
Zip two chains together using given transformation