Fix types in geometry algebras
This commit is contained in:
parent
ad66a63ac2
commit
49f0d1fe7d
@ -52,6 +52,7 @@
|
|||||||
- Median statistics
|
- Median statistics
|
||||||
- Complex power of negative real numbers
|
- Complex power of negative real numbers
|
||||||
- Add proper mutability for MutableBufferND rows and columns
|
- Add proper mutability for MutableBufferND rows and columns
|
||||||
|
- Generic Float32 and Float64 vectors are used in geometry algebras.
|
||||||
|
|
||||||
## 0.3.1 - 2023-04-09
|
## 0.3.1 - 2023-04-09
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation("org.slf4j:slf4j-simple:1.7.32")
|
implementation("org.slf4j:slf4j-simple:1.7.32")
|
||||||
// plotting
|
// plotting
|
||||||
implementation("space.kscience:plotlykt-server:0.5.3-dev-1")
|
implementation("space.kscience:plotlykt-server:0.7.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
@ -116,7 +116,7 @@ public object CMOptimizer : Optimizer<Double, FunctionOptimization<Double>> {
|
|||||||
}
|
}
|
||||||
addOptimizationData(gradientFunction)
|
addOptimizationData(gradientFunction)
|
||||||
|
|
||||||
val logger = problem.attributes[OptimizationLog]
|
// val logger = problem.attributes[OptimizationLog]
|
||||||
|
|
||||||
problem.attributes[CMOptimizerData]?.let { builders: Set<SymbolIndexer.() -> OptimizationData> ->
|
problem.attributes[CMOptimizerData]?.let { builders: Set<SymbolIndexer.() -> OptimizationData> ->
|
||||||
builders.forEach { dataBuilder ->
|
builders.forEach { dataBuilder ->
|
||||||
|
@ -26,7 +26,7 @@ public interface Float32Vector2D : Vector2D<Float32>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public object Float32Space2D : GeometrySpace<Float32Vector2D, Float32> {
|
public object Float32Space2D : GeometrySpace<Vector2D<Float32>, Float32> {
|
||||||
@Serializable
|
@Serializable
|
||||||
@SerialName("Float32Vector2D")
|
@SerialName("Float32Vector2D")
|
||||||
private data class Vector2DImpl(
|
private data class Vector2DImpl(
|
||||||
@ -54,21 +54,21 @@ public object Float32Space2D : GeometrySpace<Float32Vector2D, Float32> {
|
|||||||
|
|
||||||
override val zero: Float32Vector2D by lazy { vector(0f, 0f) }
|
override val zero: Float32Vector2D by lazy { vector(0f, 0f) }
|
||||||
|
|
||||||
override fun norm(arg: Float32Vector2D): Float32 = sqrt(arg.x.pow(2) + arg.y.pow(2))
|
override fun norm(arg: Vector2D<Float32>): Float32 = sqrt(arg.x.pow(2) + arg.y.pow(2))
|
||||||
|
|
||||||
public fun Float32Vector2D.norm(): Float32 = norm(this)
|
public fun Vector2D<Float32>.norm(): Float32 = norm(this)
|
||||||
|
|
||||||
override fun Float32Vector2D.unaryMinus(): Float32Vector2D = vector(-x, -y)
|
override fun Vector2D<Float32>.unaryMinus(): Float32Vector2D = vector(-x, -y)
|
||||||
|
|
||||||
override fun Float32Vector2D.distanceTo(other: Float32Vector2D): Float32 = (this - other).norm()
|
override fun Vector2D<Float32>.distanceTo(other: Vector2D<Float32>): Float32 = (this - other).norm()
|
||||||
|
|
||||||
override fun add(left: Float32Vector2D, right: Float32Vector2D): Float32Vector2D =
|
override fun add(left: Vector2D<Float32>, right: Vector2D<Float32>): Float32Vector2D =
|
||||||
vector(left.x + right.x, left.y + right.y)
|
vector(left.x + right.x, left.y + right.y)
|
||||||
|
|
||||||
override fun scale(a: Float32Vector2D, value: Double): Float32Vector2D =
|
override fun scale(a: Vector2D<Float32>, value: Double): Float32Vector2D =
|
||||||
vector(a.x * value, a.y * value)
|
vector(a.x * value, a.y * value)
|
||||||
|
|
||||||
override fun Float32Vector2D.dot(other: Float32Vector2D): Double =
|
override fun Vector2D<Float32>.dot(other: Vector2D<Float32>): Double =
|
||||||
(x * other.x + y * other.y).toDouble()
|
(x * other.x + y * other.y).toDouble()
|
||||||
|
|
||||||
public val xAxis: Float32Vector2D = vector(1.0, 0.0)
|
public val xAxis: Float32Vector2D = vector(1.0, 0.0)
|
||||||
@ -76,7 +76,7 @@ public object Float32Space2D : GeometrySpace<Float32Vector2D, Float32> {
|
|||||||
|
|
||||||
override val defaultPrecision: Float32 = 1e-3f
|
override val defaultPrecision: Float32 = 1e-3f
|
||||||
|
|
||||||
override val bufferFactory: MutableBufferFactory<Float32Vector2D> = MutableBufferFactory()
|
override val bufferFactory: MutableBufferFactory<Vector2D<Float32>> = MutableBufferFactory()
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun Float32Vector2D(x: Number, y: Number): Float32Vector2D = Float32Space2D.vector(x, y)
|
public fun Float32Vector2D(x: Number, y: Number): Float32Vector2D = Float32Space2D.vector(x, y)
|
||||||
|
@ -35,7 +35,7 @@ public typealias DoubleVector2D = Float64Vector2D
|
|||||||
/**
|
/**
|
||||||
* 2D Euclidean space
|
* 2D Euclidean space
|
||||||
*/
|
*/
|
||||||
public object Float64Space2D : GeometrySpace<Float64Vector2D, Float64>, ScaleOperations<Float64Vector2D> {
|
public object Float64Space2D : GeometrySpace<Vector2D<Float64>, Float64>, ScaleOperations<Vector2D<Float64>> {
|
||||||
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -61,23 +61,23 @@ public object Float64Space2D : GeometrySpace<Float64Vector2D, Float64>, ScaleOpe
|
|||||||
|
|
||||||
override val zero: Float64Vector2D by lazy { vector(0.0, 0.0) }
|
override val zero: Float64Vector2D by lazy { vector(0.0, 0.0) }
|
||||||
|
|
||||||
override fun norm(arg: Float64Vector2D): Double = sqrt(arg.x.pow(2) + arg.y.pow(2))
|
override fun norm(arg: Vector2D<Float64>): Double = sqrt(arg.x.pow(2) + arg.y.pow(2))
|
||||||
|
|
||||||
override fun Float64Vector2D.unaryMinus(): Float64Vector2D = vector(-x, -y)
|
override fun Vector2D<Float64>.unaryMinus(): Float64Vector2D = vector(-x, -y)
|
||||||
|
|
||||||
override fun Float64Vector2D.distanceTo(other: Float64Vector2D): Double = norm(this - other)
|
override fun Vector2D<Float64>.distanceTo(other: Vector2D<Float64>): Double = norm(this - other)
|
||||||
override fun add(left: Float64Vector2D, right: Float64Vector2D): Float64Vector2D =
|
override fun add(left: Vector2D<Float64>, right: Vector2D<Float64>): Float64Vector2D =
|
||||||
vector(left.x + right.x, left.y + right.y)
|
vector(left.x + right.x, left.y + right.y)
|
||||||
|
|
||||||
override fun scale(a: Float64Vector2D, value: Double): Float64Vector2D = vector(a.x * value, a.y * value)
|
override fun scale(a: Vector2D<Float64>, value: Double): Float64Vector2D = vector(a.x * value, a.y * value)
|
||||||
override fun Float64Vector2D.dot(other: Float64Vector2D): Double = x * other.x + y * other.y
|
override fun Vector2D<Float64>.dot(other: Vector2D<Float64>): Double = x * other.x + y * other.y
|
||||||
|
|
||||||
public val xAxis: Float64Vector2D = vector(1.0, 0.0)
|
public val xAxis: Float64Vector2D = vector(1.0, 0.0)
|
||||||
public val yAxis: Float64Vector2D = vector(0.0, 1.0)
|
public val yAxis: Float64Vector2D = vector(0.0, 1.0)
|
||||||
|
|
||||||
override val defaultPrecision: Double = 1e-6
|
override val defaultPrecision: Double = 1e-6
|
||||||
|
|
||||||
override val bufferFactory: MutableBufferFactory<Float64Vector2D> = MutableBufferFactory()
|
override val bufferFactory: MutableBufferFactory<Vector2D<Float64>> = MutableBufferFactory()
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun Float64Vector2D(x: Number, y: Number): Float64Vector2D = Float64Space2D.vector(x, y)
|
public fun Float64Vector2D(x: Number, y: Number): Float64Vector2D = Float64Space2D.vector(x, y)
|
||||||
|
@ -26,7 +26,7 @@ public interface Float32Vector3D : Vector3D<Float>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public object Float32Space3D : GeometrySpace<Float32Vector3D, Float32> {
|
public object Float32Space3D : GeometrySpace<Vector3D<Float32>, Float32> {
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@SerialName("Float32Vector3D")
|
@SerialName("Float32Vector3D")
|
||||||
@ -56,21 +56,21 @@ public object Float32Space3D : GeometrySpace<Float32Vector3D, Float32> {
|
|||||||
|
|
||||||
override val zero: Float32Vector3D by lazy { vector(0.0, 0.0, 0.0) }
|
override val zero: Float32Vector3D by lazy { vector(0.0, 0.0, 0.0) }
|
||||||
|
|
||||||
override fun norm(arg: Float32Vector3D): Float32 = sqrt(arg.x.pow(2) + arg.y.pow(2) + arg.z.pow(2))
|
override fun norm(arg: Vector3D<Float32>): Float32 = sqrt(arg.x.pow(2) + arg.y.pow(2) + arg.z.pow(2))
|
||||||
|
|
||||||
public fun Float32Vector3D.norm(): Float32 = norm(this)
|
public fun Vector3D<Float32>.norm(): Float32 = norm(this)
|
||||||
|
|
||||||
override fun Float32Vector3D.unaryMinus(): Float32Vector3D = vector(-x, -y, -z)
|
override fun Vector3D<Float32>.unaryMinus(): Float32Vector3D = vector(-x, -y, -z)
|
||||||
|
|
||||||
override fun Float32Vector3D.distanceTo(other: Float32Vector3D): Float32 = (this - other).norm()
|
override fun Vector3D<Float32>.distanceTo(other: Vector3D<Float32>): Float32 = (this - other).norm()
|
||||||
|
|
||||||
override fun add(left: Float32Vector3D, right: Float32Vector3D): Float32Vector3D =
|
override fun add(left: Vector3D<Float32>, right: Vector3D<Float32>): Float32Vector3D =
|
||||||
vector(left.x + right.x, left.y + right.y, left.z + right.z)
|
vector(left.x + right.x, left.y + right.y, left.z + right.z)
|
||||||
|
|
||||||
override fun scale(a: Float32Vector3D, value: Double): Float32Vector3D =
|
override fun scale(a: Vector3D<Float32>, value: Double): Float32Vector3D =
|
||||||
vector(a.x * value, a.y * value, a.z * value)
|
vector(a.x * value, a.y * value, a.z * value)
|
||||||
|
|
||||||
override fun Float32Vector3D.dot(other: Float32Vector3D): Double =
|
override fun Vector3D<Float32>.dot(other: Vector3D<Float32>): Double =
|
||||||
(x * other.x + y * other.y + z * other.z).toDouble()
|
(x * other.x + y * other.y + z * other.z).toDouble()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,7 +106,7 @@ public object Float32Space3D : GeometrySpace<Float32Vector3D, Float32> {
|
|||||||
|
|
||||||
override val defaultPrecision: Float32 = 1e-3f
|
override val defaultPrecision: Float32 = 1e-3f
|
||||||
|
|
||||||
override val bufferFactory: MutableBufferFactory<Float32Vector3D> = MutableBufferFactory()
|
override val bufferFactory: MutableBufferFactory<Vector3D<Float32>> = MutableBufferFactory()
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun Float32Vector3D(x: Number, y: Number, z: Number): Float32Vector3D = Float32Space3D.vector(x, y, z)
|
public fun Float32Vector3D(x: Number, y: Number, z: Number): Float32Vector3D = Float32Space3D.vector(x, y, z)
|
||||||
|
Loading…
Reference in New Issue
Block a user