forked from kscience/kmath
Explicit mutability for StructureND builders
This commit is contained in:
parent
cdfddb7551
commit
f09371a3f9
@ -46,7 +46,7 @@ kotlin {
|
|||||||
sourceSets {
|
sourceSets {
|
||||||
filter { it.name.contains("test", true) }
|
filter { it.name.contains("test", true) }
|
||||||
.map(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::languageSettings)
|
.map(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::languageSettings)
|
||||||
.forEach { it.optIn("space.kscience.kmath.misc.UnstableKMathAPI") }
|
.forEach { it.optIn("space.kscience.kmath.UnstableKMathAPI") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package space.kscience.kmath.ast
|
package space.kscience.kmath.ast
|
||||||
|
|
||||||
|
import space.kscience.kmath.UnstableKMathAPI
|
||||||
import space.kscience.kmath.expressions.Expression
|
import space.kscience.kmath.expressions.Expression
|
||||||
import space.kscience.kmath.expressions.MST
|
import space.kscience.kmath.expressions.MST
|
||||||
import space.kscience.kmath.expressions.Symbol
|
import space.kscience.kmath.expressions.Symbol
|
||||||
@ -17,6 +18,7 @@ import space.kscience.kmath.estree.compileToExpression as estreeCompileToExpress
|
|||||||
import space.kscience.kmath.wasm.compile as wasmCompile
|
import space.kscience.kmath.wasm.compile as wasmCompile
|
||||||
import space.kscience.kmath.wasm.compileToExpression as wasmCompileToExpression
|
import space.kscience.kmath.wasm.compileToExpression as wasmCompileToExpression
|
||||||
|
|
||||||
|
@OptIn(UnstableKMathAPI::class)
|
||||||
private object WasmCompilerTestContext : CompilerTestContext {
|
private object WasmCompilerTestContext : CompilerTestContext {
|
||||||
override fun MST.compileToExpression(algebra: IntRing): Expression<Int> = wasmCompileToExpression(algebra)
|
override fun MST.compileToExpression(algebra: IntRing): Expression<Int> = wasmCompileToExpression(algebra)
|
||||||
override fun MST.compile(algebra: IntRing, arguments: Map<Symbol, Int>): Int = wasmCompile(algebra, arguments)
|
override fun MST.compile(algebra: IntRing, arguments: Map<Symbol, Int>): Int = wasmCompile(algebra, arguments)
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package space.kscience.kmath.wasm
|
package space.kscience.kmath.wasm
|
||||||
|
|
||||||
|
import space.kscience.kmath.UnstableKMathAPI
|
||||||
import space.kscience.kmath.expressions.MstExtendedField
|
import space.kscience.kmath.expressions.MstExtendedField
|
||||||
import space.kscience.kmath.expressions.MstRing
|
import space.kscience.kmath.expressions.MstRing
|
||||||
import space.kscience.kmath.expressions.invoke
|
import space.kscience.kmath.expressions.invoke
|
||||||
@ -15,6 +16,7 @@ import space.kscience.kmath.operations.invoke
|
|||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
@OptIn(UnstableKMathAPI::class)
|
||||||
internal class TestWasmSpecific {
|
internal class TestWasmSpecific {
|
||||||
@Test
|
@Test
|
||||||
fun int() {
|
fun int() {
|
||||||
|
@ -8,7 +8,7 @@ package space.kscience.kmath.geometry
|
|||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlin.math.PI
|
import kotlin.math.PI
|
||||||
|
|
||||||
interface Circle<T>
|
public interface Circle<T>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,7 +36,7 @@ fun assertVectorEquals(expected: DoubleVector3D, actual: DoubleVector3D, absolut
|
|||||||
assertEquals(expected.z, actual.z, absoluteTolerance)
|
assertEquals(expected.z, actual.z, absoluteTolerance)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <V : Any, D: Comparable<D>> GeometrySpace<V, D>.isCollinear(a: V, b: V, absoluteTolerance: D = defaultPrecision): Boolean {
|
fun <V : Any> GeometrySpace<V, Double>.isCollinear(a: V, b: V, absoluteTolerance: Double = defaultPrecision): Boolean {
|
||||||
val aDist = a.distanceTo(zero)
|
val aDist = a.distanceTo(zero)
|
||||||
val bDist = b.distanceTo(zero)
|
val bDist = b.distanceTo(zero)
|
||||||
return aDist < absoluteTolerance || bDist < absoluteTolerance || abs(abs((a dot b) / (aDist * bDist)) - 1) < absoluteTolerance
|
return aDist < absoluteTolerance || bDist < absoluteTolerance || abs(abs((a dot b) / (aDist * bDist)) - 1) < absoluteTolerance
|
||||||
|
@ -12,10 +12,12 @@ import space.kscience.kmath.operations.Group
|
|||||||
* Get a line, containing this [LineSegment]
|
* Get a line, containing this [LineSegment]
|
||||||
*/
|
*/
|
||||||
context(Group<V>)
|
context(Group<V>)
|
||||||
public val <V : Any> LineSegment<V>.line: Line<V> get() = Line(begin, end - begin)
|
public val <V : Any> LineSegment<V>.line: Line<V>
|
||||||
|
get() = Line(begin, end - begin)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a length of a line segment
|
* Get a length of a line segment
|
||||||
*/
|
*/
|
||||||
context(GeometrySpace<V>)
|
context(GeometrySpace<V, D>)
|
||||||
public val <V : Any> LineSegment<V>.length: Double get() = norm(end - begin)
|
public val <V : Any, D : Comparable<D>> LineSegment<V>.length: D
|
||||||
|
get() = norm(end - begin)
|
Loading…
Reference in New Issue
Block a user