Requirements
| to use tda4j from | you need |
|---|---|
| Scala | Java 21 or newer, Scala 3.9 |
| Java, MATLAB, the command line | Java 21 or newer (MATLAB: a release whose bundled or configured JVM is 21 or newer) |
| JavaScript, TypeScript | a browser, or Node.js 20.16 or newer |
Everything runs on the JVM or in JavaScript; there is nothing to compile and no native library to install.
The current version is on Maven Central and in the releases; below it is written VERSION. A version that ends in -SNAPSHOT is a development build: take the daily snapshot or build it from source.
Scala
// sbt
libraryDependencies += "org.appliedtopology" %% "tda4j" % "VERSION" // sbt 2: also picks the Scala.js artifact in a Scala.js project
// Mill
mvn"org.appliedtopology::tda4j:VERSION"
// Scala CLI, at the top of the file
//> using scala 3.9.0
//> using dep org.appliedtopology::tda4j:VERSION
// Gradle (Kotlin DSL)
implementation("org.appliedtopology:tda4j_3:VERSION")
Every Scala file that uses the library starts with import scala.language.experimental.modularity (see the user guide). To check the installation:
import scala.language.experimental.modularity
import org.appliedtopology.tda4j.*
val square = Array(Array(0.0, 0.0), Array(1.0, 0.0), Array(1.0, 1.0), Array(0.0, 1.0))
Persistence(square, maxDimension = 1).bettiNumbers // Betti numbers at the end of the filtration
Java and MATLAB
Download tda4j-VERSION-assembly.jar from the releases: one jar with the library and its dependencies. Put it on the class path, or in MATLAB:
javaaddpath('/path/to/tda4j-VERSION-assembly.jar');
import org.appliedtopology.tda4j.matlab.*;
TDA4j.computeFromPoints([0 0; 1 0; 0.5 0.8], {'maxDimension', '1'})
In a Maven build, depend on org.appliedtopology:tda4j_3:VERSION; Maven brings the Scala library along. The MATLAB and Java page lists the methods.
Command line
java -jar tda4j-VERSION-assembly.jar --help
java -jar tda4j-VERSION-assembly.jar --max-dimension 1 points.csv
See the command-line page.
JavaScript and TypeScript
npm install @appliedtopology/tda4j
See the JavaScript page.
Try it without installing anything to your project
tda4j-demo-VERSION.jar from the releases is a Scala REPL with the library and its imports in place: java -jar tda4j-demo-VERSION.jar.
Development snapshots
The scala branch is published as a -SNAPSHOT of the next version (the one in version.sbt) to Maven Central's snapshot repository on every day on which a commit has landed. A snapshot is whatever the branch held at that time: it can change or break without notice, and Central deletes one after 90 days. Add the repository and ask for the snapshot version:
// sbt: NEXT-SNAPSHOT is the version in version.sbt, for example 0.7.0-SNAPSHOT
resolvers += "Central Snapshots" at "https://central.sonatype.com/repository/maven-snapshots/"
libraryDependencies += "org.appliedtopology" %% "tda4j" % "NEXT-SNAPSHOT"
Other build tools take the same repository URL, https://central.sonatype.com/repository/maven-snapshots/.
From source
git clone https://github.com/appliedtopology/tda4j
cd tda4j
sbt tda4j/publishLocal # then depend on the -SNAPSHOT version printed at the end
sbt tda4j/assembly # the fat jar, under target/out/jvm/scala-3.9.0/tda4j/
This needs Java 21 and sbt 2. CONTRIBUTING.md has the rest.
If something does not work, see troubleshooting.