v0.2.0 #206

Merged
altavir merged 210 commits from dev into master 2021-02-21 16:33:25 +03:00
2 changed files with 11 additions and 0 deletions
Showing only changes of commit df4ea2c1e4 - Show all commits

View File

@ -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]
*/

View File

@ -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