-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persistent Homology of Simplicial Sets should be working now.
- Loading branch information
Mikael Vejdemo-Johansson
committed
Jun 3, 2024
1 parent
a8b603f
commit b5fa5b7
Showing
3 changed files
with
220 additions
and
10 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
src/main/scala/org/appliedtopology/tda4j/PrintingHelper.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.appliedtopology.tda4j | ||
package unicode | ||
|
||
def applyTranslation(trMap: Map[Char,String]): (String => String) = s => | ||
s.flatMap(trMap.orElse(_.toString)) | ||
|
||
def applyCharTranslation(trMap: Map[Char,Char]): (String => String) = s => | ||
s.map(trMap.orElse{c => c}) | ||
|
||
val superScriptMap = Map( | ||
'0' -> '⁰', | ||
'1' -> '¹', | ||
'2' -> '²', | ||
'3' -> '³', | ||
'4' -> '⁴', | ||
'5' -> '⁵', | ||
'6' -> '⁶', | ||
'7' -> '⁷', | ||
'8' -> '⁸', | ||
'9' -> '⁹', | ||
'+' -> '⁺', | ||
'-' -> '⁻', | ||
'=' -> '⁼', | ||
'(' -> '⁽', | ||
')' -> '⁾', | ||
'i' -> 'ⁱ', | ||
'n' -> 'ⁿ', | ||
'h' -> 'ʰ', | ||
) | ||
|
||
val subScriptMap = Map( | ||
'i' -> 'ᵢ', | ||
'r' -> 'ᵣ', | ||
'u' -> 'ᵤ', | ||
'v' -> 'ᵥ', | ||
'0' -> '₀', | ||
'1' -> '₁', | ||
'2' -> '₂', | ||
'3' -> '₃', | ||
'4' -> '₄', | ||
'5' -> '₅', | ||
'6' -> '₆', | ||
'7' -> '₇', | ||
'8' -> '₈', | ||
'9' -> '₉', | ||
'+' -> '₊', | ||
'-' -> '₋', | ||
'=' -> '₌', | ||
'(' -> '₍', | ||
')' -> '₎', | ||
'a' -> 'ₐ', | ||
'e' -> 'ₔ', | ||
'o' -> 'ₒ', | ||
'x' -> 'ₓ', | ||
'h' -> 'ₕ', | ||
'k' -> 'ₖ', | ||
'l' -> 'ₗ', | ||
'm' -> 'ₘ', | ||
'n' -> 'ₙ', | ||
'p' -> 'ₚ', | ||
's' -> 'ₛ', | ||
't' -> 'ₜ', | ||
'j' -> 'ⱼ', | ||
) | ||
|
||
def unicodeSuperScript = applyCharTranslation(superScriptMap) | ||
def unicodeSubScript = applyCharTranslation(subScriptMap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/test/scala/org/appliedtopology/tda4j/SimplicialSetSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.appliedtopology.tda4j | ||
|
||
import org.specs2.mutable | ||
|
||
class SimplicialSetSpec extends mutable.Specification { | ||
|
||
"Homology of 4-sphere" >> { | ||
val sphere4 = sphere(4) | ||
import sphere4.given | ||
given chc: CellularHomologyContext[SimplicialSetElement, Double, Double]() | ||
import chc.{*, given} | ||
|
||
val sphere4stream = new CellStream[SimplicialSetElement, Double] { | ||
override def filtrationValue = _ => 0.0 | ||
|
||
override def iterator = sphere4.generators.iterator | ||
|
||
override def filtrationOrdering = sseOrdering | ||
|
||
override def smallest = Double.NegativeInfinity | ||
|
||
override def largest = Double.PositiveInfinity | ||
} | ||
|
||
val ph = persistentHomology(sphere4stream) | ||
val dgm = ph.diagramAt(1.0) | ||
|
||
dgm must containTheSameElementsAs(List( | ||
(0, 0.0, Double.PositiveInfinity), | ||
(4, 0.0, Double.PositiveInfinity) | ||
)) | ||
} | ||
} |