Build status for all platforms: Commercial support:
This directory contains the JavaCPP Presets module for:
Please refer to the parent README.md file for more detailed information about the JavaCPP Presets.
Java API documentation is available here:
Here is a simple example of GSL ported to Java from this demo.c source file:
We can use Maven 3 to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the pom.xml
and Demo.java
source files below, simply execute on the command line:
$ mvn compile exec:java
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.bytedeco.gsl</groupId>
<artifactId>demo</artifactId>
<version>1.5.11-SNAPSHOT</version>
<properties>
<exec.mainClass>Demo</exec.mainClass>
</properties>
<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>gsl-platform</artifactId>
<version>2.8-1.5.11-SNAPSHOT</version>
</dependency>
<!-- Additional dependencies to use bundled full version of MKL -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>mkl-platform-redist</artifactId>
<version>2024.0-1.5.11-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>.</sourceDirectory>
</build>
</project>
import org.bytedeco.javacpp.*;
import org.bytedeco.gsl.*;
import static org.bytedeco.gsl.global.gsl.*;
public class Demo {
public static void main(String[] args) {
/* try to use MKL when available */
System.setProperty("org.bytedeco.openblas.load", "mkl");
gsl_rng_type T;
gsl_rng r;
int n = 10;
double mu = 3.0;
/* create a generator chosen by the
environment variable GSL_RNG_TYPE */
gsl_rng_env_setup();
T = gsl_rng_default();
r = gsl_rng_alloc(T);
/* print n random variates chosen from
the poisson distribution with mean
parameter mu */
for (int i = 0; i < n; i++) {
int k = gsl_ran_poisson(r, mu);
System.out.printf(" %d", k);
}
System.out.println();
gsl_rng_free(r);
System.exit(0);
}
}