Grid generators moved to kmath-for-real
This commit is contained in:
parent
af306084cf
commit
a8329b2ed2
@ -15,6 +15,7 @@
|
||||
- `Fitting` utility object in prob/stat
|
||||
- ND4J support module submitting `NDStructure` and `NDAlgebra` over `INDArray`.
|
||||
- Coroutine-deterministic Monte-Carlo scope with a random number generator.
|
||||
- Some minor utilities to `kmath-for-real`.
|
||||
|
||||
### Changed
|
||||
- Package changed from `scientifik` to `kscience.kmath`.
|
||||
@ -25,12 +26,14 @@
|
||||
- `kmath-ast` doesn't depend on heavy `kotlin-reflect` library.
|
||||
- Full autodiff refactoring based on `Symbol`
|
||||
- `kmath-prob` renamed to `kmath-stat`
|
||||
- Grid generators moved to `kmath-for-real`
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
- `kmath-koma` module because it doesn't support Kotlin 1.4.
|
||||
- Support of `legacy` JS backend (we will support only IR)
|
||||
- `toGrid` method.
|
||||
|
||||
### Fixed
|
||||
- `symbol` method in `MstExtendedField` (https://github.com/mipt-npm/kmath/pull/140)
|
||||
|
@ -4,7 +4,7 @@ plugins {
|
||||
id("ru.mipt.npm.project")
|
||||
}
|
||||
|
||||
internal val kmathVersion: String by extra("0.2.0-dev-3")
|
||||
internal val kmathVersion: String by extra("0.2.0-dev-4")
|
||||
internal val bintrayRepo: String by extra("kscience")
|
||||
internal val githubProject: String by extra("kmath")
|
||||
|
||||
|
@ -5,19 +5,19 @@ package kscience.kmath.structures
|
||||
*
|
||||
* @property array the underlying array.
|
||||
*/
|
||||
@Suppress("OVERRIDE_BY_INLINE")
|
||||
public inline class RealBuffer(public val array: DoubleArray) : MutableBuffer<Double> {
|
||||
override val size: Int get() = array.size
|
||||
|
||||
override operator fun get(index: Int): Double = array[index]
|
||||
override inline operator fun get(index: Int): Double = array[index]
|
||||
|
||||
override operator fun set(index: Int, value: Double) {
|
||||
override inline operator fun set(index: Int, value: Double) {
|
||||
array[index] = value
|
||||
}
|
||||
|
||||
override operator fun iterator(): DoubleIterator = array.iterator()
|
||||
|
||||
override fun copy(): MutableBuffer<Double> =
|
||||
RealBuffer(array.copyOf())
|
||||
override fun copy(): RealBuffer = RealBuffer(array.copyOf())
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,6 +34,11 @@ public inline fun RealBuffer(size: Int, init: (Int) -> Double): RealBuffer = Rea
|
||||
*/
|
||||
public fun RealBuffer(vararg doubles: Double): RealBuffer = RealBuffer(doubles)
|
||||
|
||||
/**
|
||||
* Simplified [RealBuffer] to array comparison
|
||||
*/
|
||||
public fun RealBuffer.contentEquals(vararg doubles: Double): Boolean = array.contentEquals(doubles)
|
||||
|
||||
/**
|
||||
* Returns a [DoubleArray] containing all of the elements of this [MutableBuffer].
|
||||
*/
|
||||
|
@ -14,8 +14,9 @@ import kotlin.math.sqrt
|
||||
|
||||
public typealias RealPoint = Point<Double>
|
||||
|
||||
public fun DoubleArray.asVector(): RealVector = RealVector(asBuffer())
|
||||
public fun List<Double>.asVector(): RealVector = RealVector(asBuffer())
|
||||
public fun RealPoint.asVector(): RealVector = RealVector(this)
|
||||
public fun DoubleArray.asVector(): RealVector = asBuffer().asVector()
|
||||
public fun List<Double>.asVector(): RealVector = asBuffer().asVector()
|
||||
|
||||
public object VectorL2Norm : Norm<Point<out Number>, Double> {
|
||||
override fun norm(arg: Point<out Number>): Double = sqrt(arg.asIterable().sumByDouble(Number::toDouble))
|
||||
|
@ -1,5 +1,7 @@
|
||||
package kscience.kmath.misc
|
||||
package kscience.kmath.real
|
||||
|
||||
import kscience.kmath.linear.Point
|
||||
import kscience.kmath.structures.asBuffer
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
@ -32,6 +34,9 @@ public fun ClosedFloatingPointRange<Double>.toSequenceWithStep(step: Double): Se
|
||||
}
|
||||
}
|
||||
|
||||
public infix fun ClosedFloatingPointRange<Double>.step(step: Double): Point<Double> =
|
||||
toSequenceWithStep(step).toList().asBuffer()
|
||||
|
||||
/**
|
||||
* Convert double range to sequence with the fixed number of points
|
||||
*/
|
||||
@ -39,12 +44,3 @@ public fun ClosedFloatingPointRange<Double>.toSequenceWithPoints(numPoints: Int)
|
||||
require(numPoints > 1) { "The number of points should be more than 2" }
|
||||
return toSequenceWithStep(abs(endInclusive - start) / (numPoints - 1))
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert double range to array of evenly spaced doubles, where the size of array equals [numPoints]
|
||||
*/
|
||||
@Deprecated("Replace by 'toSequenceWithPoints'")
|
||||
public fun ClosedFloatingPointRange<Double>.toGrid(numPoints: Int): DoubleArray {
|
||||
require(numPoints >= 2) { "Can't create generic grid with less than two points" }
|
||||
return DoubleArray(numPoints) { i -> start + (endInclusive - start) / (numPoints - 1) * i }
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package kscience.kmath.real
|
||||
|
||||
import kscience.kmath.structures.RealBuffer
|
||||
|
||||
/**
|
||||
* Simplified [RealBuffer] to array comparison
|
||||
*/
|
||||
public fun RealBuffer.contentEquals(vararg doubles: Double): Boolean = array.contentEquals(doubles)
|
@ -0,0 +1,13 @@
|
||||
package kaceince.kmath.real
|
||||
|
||||
import kscience.kmath.real.step
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class GridTest {
|
||||
@Test
|
||||
fun testStepGrid(){
|
||||
val grid = 0.0..1.0 step 0.2
|
||||
assertEquals(6, grid.size)
|
||||
}
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
package scientific.kmath.real
|
||||
package kaceince.kmath.real
|
||||
|
||||
import kscience.kmath.linear.VirtualMatrix
|
||||
import kscience.kmath.linear.build
|
||||
import kscience.kmath.real.*
|
||||
import kscience.kmath.structures.Matrix
|
||||
import kscience.kmath.structures.contentEquals
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
@ -1,11 +1,14 @@
|
||||
package kscience.kmath.linear
|
||||
package kaceince.kmath.real
|
||||
|
||||
import kscience.kmath.linear.MatrixContext
|
||||
import kscience.kmath.linear.asMatrix
|
||||
import kscience.kmath.linear.transpose
|
||||
import kscience.kmath.operations.invoke
|
||||
import kscience.kmath.real.RealVector
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
internal class VectorTest {
|
||||
internal class RealVectorTest {
|
||||
@Test
|
||||
fun testSum() {
|
||||
val vector1 = RealVector(5) { it.toDouble() }
|
@ -8,8 +8,8 @@ pluginManagement {
|
||||
maven("https://dl.bintray.com/kotlin/kotlinx")
|
||||
}
|
||||
|
||||
val toolsVersion = "0.6.4-dev-1.4.20-M2"
|
||||
val kotlinVersion = "1.4.20-M2"
|
||||
val toolsVersion = "0.7.0"
|
||||
val kotlinVersion = "1.4.20"
|
||||
|
||||
plugins {
|
||||
id("kotlinx.benchmark") version "0.2.0-dev-20"
|
||||
@ -17,7 +17,7 @@ pluginManagement {
|
||||
id("ru.mipt.npm.mpp") version toolsVersion
|
||||
id("ru.mipt.npm.jvm") version toolsVersion
|
||||
id("ru.mipt.npm.publish") version toolsVersion
|
||||
kotlin("jvm") version kotlinVersion
|
||||
kotlin("jvm") version kotlinVersion
|
||||
kotlin("plugin.allopen") version kotlinVersion
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user