Merge branch 'dev' into dev-0.4
# Conflicts: # buildSrc/settings.gradle.kts # gradle.properties # gradle/wrapper/gradle-wrapper.properties # kmath-geometry/src/commonMain/kotlin/space/kscience/kmath/geometry/euclidean2d/Circle2D.kt # kmath-geometry/src/commonMain/kotlin/space/kscience/kmath/geometry/euclidean2d/Float32Space2D.kt # kmath-geometry/src/commonMain/kotlin/space/kscience/kmath/geometry/euclidean2d/Float64Space2D.kt # kmath-geometry/src/commonMain/kotlin/space/kscience/kmath/geometry/quaternionOperations.kt
This commit is contained in:
commit
544b8610e1
@ -19,6 +19,7 @@
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
- `asPolynomial` function due to scope pollution
|
||||
|
||||
### Fixed
|
||||
- Median statistics
|
||||
|
@ -1,4 +1,3 @@
|
||||
import space.kscience.gradle.isInDevelopment
|
||||
import space.kscience.gradle.useApache2Licence
|
||||
import space.kscience.gradle.useSPCTeam
|
||||
|
||||
@ -64,17 +63,10 @@ ksciencePublish {
|
||||
useApache2Licence()
|
||||
useSPCTeam()
|
||||
}
|
||||
github("kmath", "SciProgCentre")
|
||||
space(
|
||||
if (isInDevelopment) {
|
||||
"https://maven.pkg.jetbrains.space/spc/p/sci/dev"
|
||||
} else {
|
||||
"https://maven.pkg.jetbrains.space/spc/p/sci/maven"
|
||||
}
|
||||
)
|
||||
repository("spc","https://maven.sciprog.center/kscience")
|
||||
sonatype("https://oss.sonatype.org")
|
||||
}
|
||||
|
||||
apiValidation.nonPublicMarkers.add("space.kscience.kmath.UnstableKMathAPI")
|
||||
|
||||
val multikVersion by extra("0.2.0")
|
||||
val multikVersion by extra("0.2.2")
|
||||
|
@ -17,7 +17,7 @@ val benchmarksVersion = spclibs.versions.kotlinx.benchmark.get()
|
||||
dependencies {
|
||||
api("space.kscience:gradle-tools:$toolsVersion")
|
||||
//plugins form benchmarks
|
||||
api("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.4.7")
|
||||
api("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.4.9")
|
||||
//api("org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion")
|
||||
//to be used inside build-script only
|
||||
//implementation(spclibs.kotlinx.serialization.json)
|
||||
|
@ -1,4 +1,13 @@
|
||||
rootProject.name = "buildSrc"
|
||||
/*
|
||||
* Copyright 2018-2021 KMath contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
|
||||
plugins {
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
val projectProperties = java.util.Properties()
|
||||
|
@ -54,9 +54,9 @@ fun Project.addBenchmarkProperties() {
|
||||
p.extensions.findByType(KScienceReadmeExtension::class.java)?.run {
|
||||
benchmarksProject.extensions.findByType(BenchmarksExtension::class.java)?.configurations?.forEach { cfg ->
|
||||
property("benchmark${cfg.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}") {
|
||||
val launches = benchmarksProject.buildDir.resolve("reports/benchmarks/${cfg.name}")
|
||||
val launches = benchmarksProject.layout.buildDirectory.dir("reports/benchmarks/${cfg.name}").get()
|
||||
|
||||
val resDirectory = launches.listFiles()?.maxByOrNull {
|
||||
val resDirectory = launches.files().maxByOrNull {
|
||||
LocalDateTime.parse(it.name, ISO_DATE_TIME).atZone(ZoneId.systemDefault()).toInstant()
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,12 @@ kotlin.code.style=official
|
||||
kotlin.mpp.stability.nowarn=true
|
||||
kotlin.native.ignoreDisabledTargets=true
|
||||
|
||||
toolsVersion=0.14.9-kotlin-1.9.0
|
||||
org.gradle.configureondemand=true
|
||||
org.gradle.jvmargs=-Xmx4096m
|
||||
|
||||
org.gradle.parallel=true
|
||||
org.gradle.workers.max=4
|
||||
org.gradle.configureondemand=true
|
||||
org.gradle.jvmargs=-Xmx4096m
|
||||
|
||||
toolsVersion=0.15.0-kotlin-1.9.20
|
||||
#kotlin.experimental.tryK2=true
|
||||
#kscience.wasm.disabled=true
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -17,7 +17,7 @@ internal class TestFeatures {
|
||||
fun printNumeric() {
|
||||
val num = object : Number() {
|
||||
override fun toByte(): Byte = throw UnsupportedOperationException()
|
||||
override fun toChar(): Char = throw UnsupportedOperationException()
|
||||
// override fun toChar(): Char = throw UnsupportedOperationException()
|
||||
override fun toDouble(): Double = throw UnsupportedOperationException()
|
||||
override fun toFloat(): Float = throw UnsupportedOperationException()
|
||||
override fun toInt(): Int = throw UnsupportedOperationException()
|
||||
|
@ -8,9 +8,8 @@
|
||||
"OVERRIDING_FINAL_MEMBER",
|
||||
"RETURN_TYPE_MISMATCH_ON_OVERRIDE",
|
||||
"CONFLICTING_OVERLOADS",
|
||||
"NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING",
|
||||
"PropertyName",
|
||||
"ClassName",
|
||||
"ClassName", "ENUM_CLASS_IN_EXTERNAL_DECLARATION_WARNING",
|
||||
)
|
||||
|
||||
@file:JsModule("binaryen")
|
||||
@ -53,7 +52,7 @@ internal external fun createType(types: Array<Type>): Type
|
||||
|
||||
internal external fun expandType(type: Type): Array<Type>
|
||||
|
||||
internal external enum class ExpressionIds {
|
||||
internal external enum class ExpressionIds {
|
||||
Invalid,
|
||||
Block,
|
||||
If,
|
||||
|
@ -1,17 +1,20 @@
|
||||
plugins {
|
||||
id("space.kscience.gradle.jvm")
|
||||
id("space.kscience.gradle.mpp")
|
||||
}
|
||||
|
||||
description = "Commons math binding for kmath"
|
||||
|
||||
dependencies {
|
||||
api(project(":kmath-core"))
|
||||
api(project(":kmath-complex"))
|
||||
api(project(":kmath-coroutines"))
|
||||
api(project(":kmath-optimization"))
|
||||
api(project(":kmath-stat"))
|
||||
api(project(":kmath-functions"))
|
||||
api("org.apache.commons:commons-math3:3.6.1")
|
||||
kscience {
|
||||
jvm()
|
||||
jvmMain {
|
||||
api(projects.kmathCore)
|
||||
api(projects.kmathComplex)
|
||||
api(projects.kmathCoroutines)
|
||||
api(projects.kmathOptimization)
|
||||
api(projects.kmathStat)
|
||||
api(projects.kmathFunctions)
|
||||
api("org.apache.commons:commons-math3:3.6.1")
|
||||
}
|
||||
}
|
||||
|
||||
readme {
|
||||
|
@ -6,7 +6,6 @@ kscience {
|
||||
jvm()
|
||||
js()
|
||||
native()
|
||||
|
||||
wasm()
|
||||
|
||||
dependencies {
|
||||
|
@ -10,6 +10,7 @@ import space.kscience.kmath.UnstableKMathAPI
|
||||
import space.kscience.kmath.expressions.Symbol
|
||||
import space.kscience.kmath.nd.Structure2D
|
||||
import space.kscience.kmath.structures.Buffer
|
||||
import space.kscience.kmath.structures.VirtualBuffer
|
||||
import kotlin.math.max
|
||||
|
||||
/**
|
||||
@ -33,7 +34,10 @@ public interface XYColumnarData<out T, out X : T, out Y : T> : ColumnarData<T> {
|
||||
else -> null
|
||||
}
|
||||
|
||||
public companion object{
|
||||
public companion object {
|
||||
/**
|
||||
* Create data form two buffers (zero-copy)
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public fun <T, X : T, Y : T> of(x: Buffer<X>, y: Buffer<Y>): XYColumnarData<T, X, Y> {
|
||||
require(x.size == y.size) { "Buffer size mismatch. x buffer size is ${x.size}, y buffer size is ${y.size}" }
|
||||
@ -43,6 +47,26 @@ public interface XYColumnarData<out T, out X : T, out Y : T> : ColumnarData<T> {
|
||||
override val y: Buffer<Y> = y
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create two-column data from a list of row-objects (zero-copy)
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public fun <I, T, X : T, Y : T> ofList(
|
||||
list: List<I>,
|
||||
xConverter: (I) -> X,
|
||||
yConverter: (I) -> Y,
|
||||
): XYColumnarData<T, X, Y> = object : XYColumnarData<T, X, Y> {
|
||||
override val size: Int get() = list.size
|
||||
|
||||
override val x: Buffer<X> = VirtualBuffer(list.size) {
|
||||
xConverter(list[it])
|
||||
}
|
||||
|
||||
override val y: Buffer<Y> = VirtualBuffer(list.size) {
|
||||
yConverter(list[it])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,9 +80,10 @@ public fun <T> ColumnarData<T>.asXYData(
|
||||
ySymbol: Symbol,
|
||||
): XYColumnarData<T, T, T> = object : XYColumnarData<T, T, T> {
|
||||
init {
|
||||
requireNotNull(this@asXYData[xSymbol]){"The column with name $xSymbol is not present in $this"}
|
||||
requireNotNull(this@asXYData[ySymbol]){"The column with name $ySymbol is not present in $this"}
|
||||
requireNotNull(this@asXYData[xSymbol]) { "The column with name $xSymbol is not present in $this" }
|
||||
requireNotNull(this@asXYData[ySymbol]) { "The column with name $ySymbol is not present in $this" }
|
||||
}
|
||||
|
||||
override val size: Int get() = this@asXYData.size
|
||||
override val x: Buffer<T> get() = this@asXYData[xSymbol]!!
|
||||
override val y: Buffer<T> get() = this@asXYData[ySymbol]!!
|
||||
|
@ -7,7 +7,6 @@ package space.kscience.kmath.operations
|
||||
|
||||
import space.kscience.kmath.UnstableKMathAPI
|
||||
import space.kscience.kmath.expressions.Symbol
|
||||
import space.kscience.kmath.expressions.symbol
|
||||
|
||||
/**
|
||||
* An algebra for generic boolean logic
|
||||
@ -61,8 +60,8 @@ public interface LogicAlgebra<T : Any> : Algebra<T> {
|
||||
|
||||
|
||||
public companion object {
|
||||
public val TRUE: Symbol by symbol
|
||||
public val FALSE: Symbol by symbol
|
||||
public val TRUE: Symbol = Symbol("TRUE")//by symbol
|
||||
public val FALSE: Symbol = Symbol("FALSE")// by symbol
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,9 +65,7 @@ public class RingBuffer<T>(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
private inline fun Int.forward(n: Int): Int = (this + n) % (buffer.size)
|
||||
private fun Int.forward(n: Int): Int = (this + n) % (buffer.size)
|
||||
|
||||
override fun toString(): String = Buffer.toString(this)
|
||||
|
||||
|
@ -6,16 +6,26 @@
|
||||
package space.kscience.kmath.geometry.euclidean2d
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import space.kscience.kmath.geometry.Vector2D
|
||||
import kotlin.math.PI
|
||||
|
||||
|
||||
public interface Circle2D<T>{
|
||||
public val center: Vector2D<T>
|
||||
public val radius: Double
|
||||
}
|
||||
|
||||
public val Circle2D<*>.circumference: Double get() = radius * 2 * PI
|
||||
|
||||
/**
|
||||
* A circle in 2D space
|
||||
*/
|
||||
@Serializable
|
||||
public data class Circle2D(
|
||||
@Serializable(Float64Space2D.VectorSerializer::class) public val center: DoubleVector2D,
|
||||
public val radius: Double,
|
||||
)
|
||||
public data class Float64Circle2D(
|
||||
@Serializable(Float64Space2D.VectorSerializer::class) override val center: Float64Vector2D,
|
||||
override val radius: Double
|
||||
): Circle2D<Double>
|
||||
|
||||
public fun Circle2D(center: Float64Vector2D, radius: Double): Circle2D<Double> = Float64Circle2D(center, radius)
|
||||
|
||||
|
||||
public val Circle2D.circumference: Double get() = radius * 2 * PI
|
||||
|
@ -15,6 +15,7 @@ import space.kscience.kmath.geometry.GeometrySpace
|
||||
import space.kscience.kmath.geometry.Vector2D
|
||||
import space.kscience.kmath.linear.Float64LinearSpace
|
||||
import space.kscience.kmath.operations.Float64Field
|
||||
import space.kscience.kmath.operations.ScaleOperations
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.sqrt
|
||||
|
||||
@ -28,9 +29,7 @@ public val Vector2D<Double>.r: Double get() = Float64Space2D.norm(this)
|
||||
/**
|
||||
* 2D Euclidean space
|
||||
*/
|
||||
public object Float64Space2D : GeometrySpace<DoubleVector2D, Double> {
|
||||
|
||||
public val linearSpace: Float64LinearSpace = Float64LinearSpace
|
||||
public object Float64Space2D : GeometrySpace<DoubleVector2D>, ScaleOperations<DoubleVector2D> {
|
||||
|
||||
@Serializable
|
||||
@SerialName("Float64Vector2D")
|
||||
@ -72,4 +71,6 @@ public object Float64Space2D : GeometrySpace<DoubleVector2D, Double> {
|
||||
override val defaultPrecision: Double = 1e-6
|
||||
}
|
||||
|
||||
public fun Float64Vector2D(x: Number, y: Number): Float64Vector2D = Float64Space2D.vector(x, y)
|
||||
|
||||
public val Float64Field.euclidean2D: Float64Space2D get() = Float64Space2D
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2018-2023 KMath contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package space.kscience.kmath.geometry
|
||||
|
||||
import space.kscience.kmath.complex.Quaternion
|
||||
import space.kscience.kmath.complex.QuaternionAlgebra
|
||||
import space.kscience.kmath.complex.conjugate
|
||||
import space.kscience.kmath.geometry.euclidean3d.theta
|
||||
|
||||
public operator fun Quaternion.times(other: Quaternion): Quaternion = QuaternionAlgebra.multiply(this, other)
|
||||
|
||||
public operator fun Quaternion.div(other: Quaternion): Quaternion = QuaternionAlgebra.divide(this, other)
|
||||
|
||||
public fun Quaternion.power(number: Number): Quaternion = QuaternionAlgebra.power(this, number)
|
||||
|
||||
/**
|
||||
* Linear interpolation between [from] and [to] in spherical space
|
||||
*/
|
||||
public fun QuaternionAlgebra.slerp(from: Quaternion, to: Quaternion, fraction: Double): Quaternion =
|
||||
(to / from).pow(fraction) * from
|
||||
|
||||
/**
|
||||
* Scalar angle between two quaternions
|
||||
*/
|
||||
public fun QuaternionAlgebra.angleBetween(q1: Quaternion, q2: Quaternion): Angle = (q1.conjugate * q2).theta
|
||||
|
||||
/**
|
||||
* Euclidean product of two quaternions
|
||||
*/
|
||||
public infix fun Quaternion.dot(other: Quaternion): Double = w * other.w + x * other.x + y * other.y + z * other.z
|
||||
|
||||
//
|
||||
///**
|
||||
// * Convert a quaternion to XYZ Cardan angles assuming it is normalized.
|
||||
// */
|
||||
//private fun Quaternion.normalizedToEuler(): Float32Vector3D {
|
||||
// val roll = atan2(2 * y * w + 2 * x * z, 1 - 2 * y * y - 2 * z * z)
|
||||
// val pitch = atan2(2 * x * w - 2 * y * z, 1 - 2 * x * x - 2 * z * z)
|
||||
// val yaw = asin(2 * x * y + 2 * z * w)
|
||||
//
|
||||
// return Float32Vector3D(roll, pitch, yaw)
|
||||
//}
|
||||
|
||||
///**
|
||||
// * Quaternion to XYZ Cardan angles
|
||||
// */
|
||||
//public fun Quaternion.toEuler(): Float32Vector3D = if (QuaternionAlgebra.norm(this) == 0.0) {
|
||||
// Float32Space3D.zero
|
||||
//} else {
|
||||
// normalized().normalizedToEuler()
|
||||
//}
|
@ -15,3 +15,6 @@ readme {
|
||||
An API and basic implementation for arranging objects in a continuous memory block.
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
//rootProject.the<NodeJsRootExtension>().versions.webpack.version = "5.76.2"
|
||||
//rootProject.the<NodeJsRootExtension>().nodeVersion = "20.8.0"
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package space.kscience.kmath.memory
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
|
||||
@PublishedApi
|
||||
internal class NativeMemory(
|
||||
val array: ByteArray,
|
||||
@ -26,6 +28,7 @@ internal class NativeMemory(
|
||||
return NativeMemory(copy)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalNativeApi::class)
|
||||
private val reader: MemoryReader = object : MemoryReader {
|
||||
override val memory: Memory get() = this@NativeMemory
|
||||
|
||||
@ -48,6 +51,7 @@ internal class NativeMemory(
|
||||
|
||||
override fun reader(): MemoryReader = reader
|
||||
|
||||
@OptIn(ExperimentalNativeApi::class)
|
||||
private val writer: MemoryWriter = object : MemoryWriter {
|
||||
override val memory: Memory get() = this@NativeMemory
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user