This is a Groovy library (that also works in Java) to make it easy to work with
a matrix (tabular i.e. 2-dimensional) data. Whenever you ḧave a structure like this
List<List<?>> (typically defined in
Groovy like this def myList = [ [1,2,3], [3.4, 7.12, 0.19] ]) a Matrix or
a Grid can greatly enhance the experience of working with that data structure.
The Matrix project consist of the following modules:
- matrix-core The matrix-core is the heart of the matrix project. It contains the Matrix and Grid classes as well as several utility classes to do basic statistics (sum, mean, median, sd, variance, counts, frequency etc.) and to convert data into various shapes and formats See tests for more usage examples or the javadocs for more info.
- matrix-stats The stats library contains various statistical methods and tests (correlations, normalization, linear regression, t-test, etc.)
- matrix-datasets contains some common datasets used in R and Python such as mtcars, iris, diamonds, plantgrowth, toothgrowth etc.
- matrix-spreadsheet provides ways to import and export between a Matrix and an Excel or OpenOffice Calc spreadsheet
- matrix-gsheets provides ways to import and export between a Matrix and a Google Sheets spreadsheet
- matrix-csv provides a more advanced way to import and export between a Matrix and a CSV file using commons-csv(matrix-core has basic support for doing this built in)
- matrix-json provides ways to import and export between a Matrix and Json
- matrix-xcharts allows you to create charts in various formats (file, svg, swing) based on Matrix data and the XCharts library.
- matrix-sql relational database interaction
- matrix-bom Bill of materials for simpler dependency management.
- matrix-parquet provides ways to import and export between Matrix and Parquet.
- matrix-avro provides ways to import and export between Matrix and Avro. Experimental
- matrix-bigquery provides ways to import and export between Matrix and Google Big Query.
- matrix-charts allows you to create charts in various formats (file, javafx, svg) based on Matrix data. Experimental
- matrix-tablesaw interoperability between Matrix and the Tablesaw library. Experimental
Matrix should work with any 4.x version of groovy. Binary builds can be downloaded from the Matrix project release page but if you use a build system that handles dependencies via maven central (gradle, maven ivy etc.) you can add your dependencies from there . The group name is se.alipsa.matrix. The version numbers of the matrix modules does not align with each other so a way to handle this in a simpler way is to use the bom file.
An example for matrix-core is as follows for Gradle
implementation(platform( 'se.alipsa.matrix:matrix-bom:2.3.0'))
implementation('se.alipsa.matrix:matrix-core')...or the following for maven
<project>
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>se.alipsa.matrix</groupId>
<artifactId>matrix-bom</artifactId>
<version>2.3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>se.alipsa.matrix</groupId>
<artifactId>matrix-core</artifactId>
</dependency>
</dependencies>
...
</project>The project requires JDK 21. While some modules may work with higher JDK versions, the following constraints apply:
| Module(s) | Constraint | Reason |
|---|---|---|
| matrix-parquet, matrix-avro | JDK 21 max | Hadoop 3.4.x dependencies do not support JDK 22+ |
| matrix-charts | JDK 21 max | JavaFX 23.x is the latest version compatible with JDK 21; JavaFX 24+ requires JDK 22+ |
| matrix-smile | JDK 21 min | Smile 4.x is used (requires at least java 21; Smile 5+ requires Java 25) |
Since Matrix is a library, it makes sense to stay on java 21 to ensure compatibility across all modules for the foreseeable future.
These constraints are enforced in build.gradle via dependency version ceiling rules.
For more information see the tutorial and the readme file and test classes in each subproject.