{"id":37016525,"url":"https://github.com/jenetics/lattices","last_synced_at":"2026-01-14T01:52:15.680Z","repository":{"id":64115281,"uuid":"254650850","full_name":"jenetics/lattices","owner":"jenetics","description":"Library for multidimensional data structures and matrices","archived":false,"fork":false,"pushed_at":"2024-01-28T15:45:39.000Z","size":3587,"stargazers_count":7,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-01-28T16:41:30.393Z","etag":null,"topics":["high-performance-computing","java","java17","lattice","linear-algebra","mathematics","matrices","matrix-decompositions","matrix-library","multidimensional-arrays","statistics"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jenetics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-04-10T14:11:13.000Z","updated_at":"2024-01-14T00:01:08.000Z","dependencies_parsed_at":"2023-11-19T02:38:12.351Z","dependency_job_id":"293733bc-755c-44c0-bd36-00d08d7ca877","html_url":"https://github.com/jenetics/lattices","commit_stats":{"total_commits":243,"total_committers":2,"mean_commits":121.5,"dds":"0.20576131687242794","last_synced_commit":"88fe2453d3d4c92270122fa6bdd30b3384c142b8"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/jenetics/lattices","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenetics%2Flattices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenetics%2Flattices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenetics%2Flattices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenetics%2Flattices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jenetics","download_url":"https://codeload.github.com/jenetics/lattices/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenetics%2Flattices/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408692,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["high-performance-computing","java","java17","lattice","linear-algebra","mathematics","matrices","matrix-decompositions","matrix-library","multidimensional-arrays","statistics"],"created_at":"2026-01-14T01:52:15.207Z","updated_at":"2026-01-14T01:52:15.674Z","avatar_url":"https://github.com/jenetics.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Build Status](https://github.com/jenetics/lattices/actions/workflows/gradle.yml/badge.svg)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.jenetics/lattices/badge.svg)](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22lattices%22)\n[![Javadoc](https://www.javadoc.io/badge/io.jenetics/lattices.svg)](http://www.javadoc.io/doc/io.jenetics/lattices)\n\n# Lattices\n\nThis library offers an object-oriented abstraction for modelling multidimensional _rectangular_ lattices. It is designed to be scalable in terms of performance and memory usage. Its architecture was inspired by the [Colt](https://dst.lbl.gov/ACSSoftware/colt/) library, but the current design and its implementation has been brought into the _modern_ Java world.\n\nThe library contains of two modules. The `io.jenetics.lattices.structure` module defines the mapping values of _multi_-dimensional coordinates onto one-dimensional arrays. This module also contains _view_- and _projection_ functions. The main module, `io.jenetics.lattices` contains the _multi_-dimensional data structures and matrix classes for doing linear algebra.\n\n\u003e **Note:** The main design principle of the library is, that everything is a _view_. No data is actually copied for every transformation applied. A copy is only performed, if explicitly requested. Mutability is embraced.\n\n## Build the library\n\n**Lattices** requires at least **Java 17** to compile and run.\n\nCheck out the master branch from GitHub.\n\n    $ git clone https://github.com/jenetics/lattices.git \u003cbuilddir\u003e\n\n_Lattices_ uses [Gradle](http://www.gradle.org/downloads) as build system.\n\n## `io.jenetics.lattices.structure`\n\nThis module is used for defining the mappings from _n_-d space to the _1_-d space. It doesn't contain any concrete data structures containing _n_-dimensional points.\n\n```java\n// Interface for calculating the array offset for a given 2-d coordinate.\npublic interface Mapper2d {\n    // Return the (array) offset (index) of the given [row, col] point.\n    int offset(int row, int col);\n    // Return the index point for the given (array) offset.\n    Index2d index(int offset);\n}\n```\n\nThe main entry point for creating mapper functions is the `Structure\u003cN\u003ed` class, which can be created the following way.\n\n```java\n// Defining the extent of the 2-d structure.\nfinal var extent = new Extent2d(100, 400);\n\n// Creating the 2-d structure.\nfinal var structure = new Structure2d(extent);\n\n// The structure layout.\nfinal var layout = structure.layout();\n\n// Creating the array, which holds the values to be stored.\nfinal var values = new double[extent.cells()];\n\n// Set the value 'Math.PI' at the point [20, 30];\nvalues[layout.offset(20, 30)] = Math.PI;\n```\n\nBeside this basic functionality, the _View_ and _Projection_ functions are able to do some basic transformations of the _n_-d data, without copying actual data.\n\n```java\n// Create the range of the view to be created.\nfinal var range = new Range2d(\n    // Start index of the range.\n    new Index2d(5, 5),\n    // Extent of the range.\n    new Extend2d(50, 50)\n);\n\n// Create the view function with the given range.\nfinal var view = View2d.of(range)\n\n// Create a new structure (view) from the previous one.\nfinal var structure2 = view.apply(structure);\n\n// The value Math.PI is now located at position [15, 25], \n// since we we created a view from the original structure, \n// which started at point [5, 5].    \nassert values[structure2.layout().offset(15, 25)] == Math.PI;\n```\n\nThe _view_ functions don't change the dimensionality of the structure, in contrast to the _projection_ functions, which reduces the dimensionality by one.\n\n```java\n// Create a projection for row 20.\nfinal var projection = Projection2d.row(20);\n\n// Create a one-dimensional structure.\nfinal Structure1d structure3 = projection.apply(structure);\n\n// At index 25, we can access our stored value.\nassert values[structure3.layout().offset(30)] == Math.PI;\n```\n\nIt is off course possible to create a _projection_ from a structure _view_.\n\n```java\n// Create a projection for row 20.\nfinal var projection = Projection2d.row(15);\n\n// Create a one-dimensional structure.\nfinal Structure1d structure4 = projection.apply(structure2);\n\n// At index 25, we can access our stored value.\nassert values[structure4.layout().offset(25)] == Math.PI;\n```\n\nOr you can compose _projection_ and _view_ functions.\n\n```java\n// Create a projection for row 20.\nfinal var projection = Projection2d.row(15)\n    .compose(View2d.of(range));\n\n// Create a one-dimensional structure.\nfinal Structure1d structure5 = projection.apply(structure);\n\n// At index 25, we can access our stored value.\nassert values[structure5.offset(25)] == Math.PI;\n```\n\n\n## `io.jenetics.lattices.grid`\n\nThis module defines _multi_-dimensional data structures and matrix classes for doing linear algebra.\n\n### Grid\n\n_Grids_ are multidimensional views onto one-dimensional arrays. This approach makes the implementation of the _matrices_ in this library very flexible and configurable. It is possible to configure the _structure_ (extent and iteration order) independently of the layout of the underlying array (dense or sparse). How this can be done is shown in the following example.\n\n```java\n// Double array, which is created somewhere else.\nfinal var data = new double[10*15];\n// Wrap the data into an array. This is just a view, no\n// actual data are copied.\nfinal var array = new DenseDoubleArray(data);\n\n// Define the structure (extent) of your 2-d grid.\nfinal var structure = new Structure2d(new Extent2d(10, 15));\n// Create the grid with your defined structure and data.\n// The grid is a 2-d view onto your one-dimensional double array.\nfinal var grid = new DoubleGrid2d(structure, array);\n\n// Assign each grid element the value 42.\ngrid.forEach((i, j) -\u003e grid.set(i, j, 42.0));\n\n// The value is written to the underlying double[] array\nfor (var value : data) {\n    assertThat(value).isEqualTo(42.0);\n}\n```\n\n### Matrix\n\n_Matrices_ are extending _grids_ and share the same design principles. They are also highly configurable and are _just_ multidimensional _views_ onto the underlying one-dimensional arrays. Additionally, they support the usual linear algebra functionality.\n\n```java\n// Creating matrix via factory.\nfinal var A = DoubleMatrix2d.DENSE.create(3, 3);\nA.assign(new double[][] {\n    {1, 2, 3},\n    {4, 5, 6},\n    {7, 8, 9}\n});\n\n// \"Direct\" creation from element array. Faster and\n// doesn't create additional objects.\nfinal var B = DoubleMatrix2d.of(\n    new Extent2d(3, 3),\n    10, 11, 12\n    13, 14, 15,\n    16, 17, 18\n);\n    \n// Create a new matrix with the same extent than B.\nvar C = B.like();\n\n// Do the matrix multiplication C = A*B.\nA.mult(B, C);\n\n// Multiply A*B and let C create.\nC = A.mult(B, null);\n    \n// The result of the multiplication.    \n// [[84.0, 90.0, 96.0]\n//  [201.0, 216.0, 231.0]\n//  [318.0, 342.0, 366.0]]\n```\n\nThe `Algebra` and the `Blas` class contains additional operations.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenetics%2Flattices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjenetics%2Flattices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenetics%2Flattices/lists"}