Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.niltonvasques:mathjs-android:v0.2.1'
}
dependencies {
implementation("com.github.niltonvasques:mathjs-android:v0.2.1")
}
<dependency>
<groupId>com.github.niltonvasques</groupId>
<artifactId>mathjs-android</artifactId>
<version>v0.2.1</version>
</dependency>
libraryDependencies += "com.github.niltonvasques" % "mathjs-android" % "v0.2.1"
:dependencies [[com.github.niltonvasques/mathjs-android "v0.2.1"]]
An android wrapper library to mathjs.org javascript library
Mathjs is available on jitpack.
Add jitpack to your root build.gradle:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Add the library to app build.gradle
compile 'com.github.niltonvasques:mathjs-android:v0.2.1'
MathJS math = new MathJS();
// Synchronously evaluating
String answer = math.eval("2 * 5 ^ 2");
// Asynchronously evaluating
math.asyncEval("2 * 5 ^ 2 + 33", new MathJS.MathJSResult() {
@Override
public void onEvaluated(String value) {
System.out.println("MathJS.onEvaluated "+value);
}
});
math.destroy(); //Call after the library been used
To see more syntax examples see official #eval() docs from mathjs
// expressions
math.eval('1.2 * (2 + 4.5)'); // 7.8
math.eval('5.08 cm to inch'); // 2 inch
math.eval('sin(45 deg) ^ 2'); // 0.5
math.eval('9 / 3 + 2i'); // 3 + 2i
math.eval('det([-1, 2; 3, 1])'); // -7