Skip to content

Commit

Permalink
Followed up on code warnings and errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikael Vejdemo-Johansson committed Feb 21, 2024
1 parent 1db5e7e commit bf84601
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/commonMain/kotlin/org/appliedtopology/tda4j/Chain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public open class Chain<VertexT, CoefficientT> protected constructor(

public operator fun <VertexT : Comparable<VertexT>, CoefficientT> invoke(
chainMap: MutableMap<AbstractSimplex<VertexT>, CoefficientT>,
) = Chain(naturalOrder(), SimplexComparator(), chainMap)
): Chain<VertexT, CoefficientT> = Chain(naturalOrder(), SimplexComparator(), chainMap)

public operator fun <VertexT, CoefficientT> invoke(
vertexComparator: Comparator<VertexT>,
Expand Down Expand Up @@ -159,7 +159,7 @@ public class ChainContext<VertexT, CoefficientT> protected constructor(

public operator fun <VertexT : Comparable<VertexT>, CoefficientT> invoke(
coefficientContext: FieldContext<CoefficientT>,
): ChainContext<VertexT, CoefficientT> = ChainContext(kotlin.comparisons.naturalOrder<VertexT>(), coefficientContext)
): ChainContext<VertexT, CoefficientT> = ChainContext(naturalOrder(), coefficientContext)

public operator fun <VertexT : Comparable<VertexT>> invoke(): ChainContext<VertexT, Double> =
ChainContext(naturalOrder(), DoubleContext)
Expand Down
2 changes: 2 additions & 0 deletions src/commonMain/kotlin/org/appliedtopology/tda4j/Field.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public object DoubleContext : FieldContext<Double> {
override val zero: Double
get() = 0.0

override fun Double.unaryMinus(): Double = this@unaryMinus.unaryMinus()

override fun multiply(
left: Double,
right: Double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public open class FiniteFieldContext(public val p: Int) : FieldContext<Fp>, FpFa
var v = p
var x1 = 1
var x2 = 0
var q = 0
var r = 0
var x = 0
var q: Int
var r: Int
var x: Int
while (u != 1) {
q = v.floorDiv(u)
r = v - q * u
Expand Down
4 changes: 2 additions & 2 deletions src/commonTest/kotlin/org/appliedtopology/tda4j/ChainSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ class ChainSpec : StringSpec({
val singleQueryNull = chain1[simplexOf(3, 4)]
// val severalQuery = chain1[listOf(simplexOf(2, 3), simplexOf(1, 2))]

singleQuery?.shouldBeEqual(1.0)
singleQuery.shouldBeEqual(1.0)

singleQueryNull?.shouldBeEqual(0.0)
singleQueryNull.shouldBeEqual(0.0)

// severalQuery shouldBeEqual mapOf(simplexOf(2, 3) to 1, simplexOf(1, 2) to 2)
}
Expand Down

0 comments on commit bf84601

Please sign in to comment.