Reformat code

This commit is contained in:
Alexander Nozik 2021-03-15 14:26:59 +03:00
parent 0e0deaeb72
commit d9743978ab
18 changed files with 30 additions and 29 deletions

View File

@ -10,7 +10,7 @@ import space.kscience.kmath.nd.NDStructure
public class VirtualMatrix<T : Any>(
override val rowNum: Int,
override val colNum: Int,
public val generator: (i: Int, j: Int) -> T
public val generator: (i: Int, j: Int) -> T,
) : Matrix<T> {
override val shape: IntArray get() = intArrayOf(rowNum, colNum)

View File

@ -65,7 +65,8 @@ public interface NDAlgebra<T, C: Algebra<T>> {
* @param structures the structures to check.
* @return the array of valid structures.
*/
internal fun <T, C: Algebra<T>> NDAlgebra<T, C>.checkShape(vararg structures: NDStructure<T>): Array<out NDStructure<T>> = structures
internal fun <T, C : Algebra<T>> NDAlgebra<T, C>.checkShape(vararg structures: NDStructure<T>): Array<out NDStructure<T>> =
structures
.map(NDStructure<T>::shape)
.singleOrNull { !shape.contentEquals(it) }
?.let<IntArray, Array<out NDStructure<T>>> { throw ShapeMismatchException(shape, it) }

View File

@ -24,7 +24,7 @@ public open class MemoryBuffer<T : Any>(protected val memory: Memory, protected
public inline fun <T : Any> create(
spec: MemorySpec<T>,
size: Int,
initializer: (Int) -> T
initializer: (Int) -> T,
): MemoryBuffer<T> = MutableMemoryBuffer(Memory.allocate(size * spec.objectSize), spec).also { buffer ->
(0 until size).forEach { buffer[it] = initializer(it) }
}
@ -53,7 +53,7 @@ public class MutableMemoryBuffer<T : Any>(memory: Memory, spec: MemorySpec<T>) :
public inline fun <T : Any> create(
spec: MemorySpec<T>,
size: Int,
initializer: (Int) -> T
initializer: (Int) -> T,
): MutableMemoryBuffer<T> = MutableMemoryBuffer(Memory.allocate(size * spec.objectSize), spec).also { buffer ->
(0 until size).forEach { buffer[it] = initializer(it) }
}