Fix broken APIs in kmath-for-real
This commit is contained in:
parent
4433da9acf
commit
6fb3c03e87
@ -3,16 +3,26 @@ package kscience.kmath.real
|
||||
import kscience.kmath.linear.Point
|
||||
import kscience.kmath.operations.Norm
|
||||
import kscience.kmath.structures.Buffer
|
||||
import kscience.kmath.structures.RealBuffer
|
||||
import kscience.kmath.structures.asBuffer
|
||||
import kscience.kmath.structures.asIterable
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.sqrt
|
||||
|
||||
public typealias RealVector = Point<Double>
|
||||
|
||||
public inline fun RealVector(size: Int, init: (Int) -> Double): RealVector = RealBuffer(size, init)
|
||||
public fun RealVector(vararg doubles: Double): RealVector = RealBuffer(doubles)
|
||||
|
||||
public fun DoubleArray.asVector(): RealVector = asBuffer()
|
||||
public fun List<Double>.asVector(): RealVector = asBuffer()
|
||||
|
||||
|
||||
public object VectorL2Norm : Norm<Point<out Number>, Double> {
|
||||
override fun norm(arg: Point<out Number>): Double = sqrt(arg.asIterable().sumByDouble(Number::toDouble))
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fill the vector of given [size] with given [value]
|
||||
*/
|
||||
|
@ -5,6 +5,7 @@ import kscience.kmath.linear.asMatrix
|
||||
import kscience.kmath.linear.transpose
|
||||
import kscience.kmath.operations.invoke
|
||||
import kscience.kmath.real.RealVector
|
||||
import kscience.kmath.real.plus
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user