{"id":28499863,"url":"https://github.com/kotlin/multik","last_synced_at":"2026-04-22T03:00:43.715Z","repository":{"id":38185334,"uuid":"265785552","full_name":"Kotlin/multik","owner":"Kotlin","description":"Multidimensional array library for Kotlin","archived":false,"fork":false,"pushed_at":"2026-04-21T22:18:15.000Z","size":2244,"stargazers_count":721,"open_issues_count":62,"forks_count":49,"subscribers_count":14,"default_branch":"develop","last_synced_at":"2026-04-21T22:38:18.103Z","etag":null,"topics":["kotlin","matrix","multiplatform","ndarray"],"latest_commit_sha":null,"homepage":"https://kotlin.github.io/multik/","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kotlin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-05-21T07:37:29.000Z","updated_at":"2026-04-21T22:18:19.000Z","dependencies_parsed_at":"2024-02-08T22:14:10.058Z","dependency_job_id":"9ea0aa68-ec96-41f8-912f-7775898a1dad","html_url":"https://github.com/Kotlin/multik","commit_stats":{"total_commits":486,"total_committers":16,"mean_commits":30.375,"dds":0.3477366255144033,"last_synced_commit":"509b3493dfabf4cdf9f5b79b20676191accb05ba"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/Kotlin/multik","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fmultik","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fmultik/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fmultik/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fmultik/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kotlin","download_url":"https://codeload.github.com/Kotlin/multik/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fmultik/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32119065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T00:31:26.853Z","status":"online","status_checked_at":"2026-04-22T02:00:05.693Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["kotlin","matrix","multiplatform","ndarray"],"created_at":"2025-06-08T15:05:07.873Z","updated_at":"2026-04-22T03:00:43.695Z","avatar_url":"https://github.com/Kotlin.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Kotlin Alpha](https://kotl.in/badges/alpha.svg)](https://kotlinlang.org/docs/components-stability.html)\n[![JetBrains incubator project](https://jb.gg/badges/incubator.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)\n[![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/multik-core)](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/multik-core)\n[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)\n\n\u003c!---IMPORT samples.ReadmeSnippets--\u003e\n\n# Multik\n\nMultidimensional array library for Kotlin.\n\nMultik provides N-dimensional arrays with type-safe dimensions, math operations, linear algebra, and statistics.\nIt works across JVM, JS, WasmJS, iOS, and desktop native targets via Kotlin Multiplatform,\nwith optional OpenBLAS acceleration for high performance.\n\n## Modules\n\n| Module              | Description                                                                                           |\n|---------------------|-------------------------------------------------------------------------------------------------------|\n| **multik-core**     | Core ndarray types, the `mk` entry point, and Math/LinAlg/Statistics API interfaces. All platforms.   |\n| **multik-default**  | Combines `multik-kotlin` and `multik-openblas` for optimal performance on every platform.             |\n| **multik-kotlin**   | Pure Kotlin implementation. JVM, JS, WasmJS, iOS, and desktop native.                                 |\n| **multik-openblas** | Native implementation backed by OpenBLAS via C++/JNI. JVM and desktop native (macOS, Linux, Windows). |\n\n## Installation\n\nLatest\nversion: [![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/multik-core)](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/multik-core)\n\n### Gradle Kotlin DSL\n\n`multik-core` provides ndarray types, creation functions, and basic operations.\n\nFor linear algebra, statistics, and math engines, add an engine dependency —\n`multik-default`, `multik-kotlin`, or `multik-openblas`.\nEngine dependencies transitively include `multik-core`.\n\n`build.gradle.kts`:\n\n```kotlin\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation(\"org.jetbrains.kotlinx:multik-default:$multikVersion\")\n}\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eGradle Groovy DSL\u003c/summary\u003e\n\n`build.gradle`:\n\n```groovy\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation \"org.jetbrains.kotlinx:multik-default:$multikVersion\"\n}\n```\n\n\u003c/details\u003e\n\n### Kotlin Multiplatform\n\n```kotlin\nkotlin {\n    sourceSets {\n        commonMain {\n            dependencies {\n                implementation(\"org.jetbrains.kotlinx:multik-default:$multikVersion\")\n            }\n        }\n    }\n}\n```\n\n### Jupyter Notebook\n\nInstall [Kotlin kernel](https://github.com/Kotlin/kotlin-jupyter) for\n[Jupyter](https://jupyter.org/)\nor just visit to [Datalore](https://datalore.jetbrains.com/).\n\nImport stable `multik` version into notebook:\n\n```\n%use multik\n```\n\n## Supported Platforms\n\n|       Platform        | `multik-core` | `multik-kotlin` | `multik-openblas` | `multik-default` |\n|:---------------------:|:-------------:|:---------------:|:-----------------:|:----------------:|\n|        **JVM**        |       ✅       |        ✅        |         ✅         |        ✅         |\n|        **JS**         |       ✅       |        ✅        |         —         |        ✅         |\n|      **WasmJS**       |       ✅       |        ✅        |         —         |        ✅         |\n|     **linuxX64**      |       ✅       |        ✅        |         ✅         |        ✅         |\n|     **mingwX64**      |       ✅       |        ✅        |         ✅         |        ✅         |\n|    **macosArm64**     |       ✅       |        ✅        |         ✅         |        ✅         |\n|     **iosArm64**      |       ✅       |        ✅        |         —         |        ✅         |\n|      **iosX64**       |       ✅       |        ✅        |         —         |        ✅         |\n| **iosSimulatorArm64** |       ✅       |        ✅        |         —         |        ✅         |\n\n\u003e [!IMPORTANT]\n\u003e - On Linux distributions with **glibc** older than 2.31, `multik-openblas` doesn't work.\n\u003e - `multik-openblas` for desktop native targets (_linuxX64_, _mingwX64_, _macosArm64_) is experimental and\n\u003e unstable.\n\u003e - JVM target `multik-openblas` for Android only supports **arm64-v8a** processors.\n\n## Quickstart\n\nVisit [Multik documentation](https://kotlin.github.io/multik) for a detailed feature overview.\n\n### Creating arrays\n\n\u003c!---FUN creatingArrays--\u003e\n\n```kotlin\nval a = mk.ndarray(mk[1, 2, 3])\n/* [1, 2, 3] */\n\nval b = mk.ndarray(mk[mk[1.5, 2.1, 3.0], mk[4.0, 5.0, 6.0]])\n/*\n[[1.5, 2.1, 3.0],\n[4.0, 5.0, 6.0]]\n*/\n\nval c = mk.ndarray(mk[mk[mk[1.5f, 2f, 3f], mk[4f, 5f, 6f]], mk[mk[3f, 2f, 1f], mk[4f, 5f, 6f]]])\n/*\n[[[1.5, 2.0, 3.0],\n[4.0, 5.0, 6.0]],\n\n[[3.0, 2.0, 1.0],\n[4.0, 5.0, 6.0]]]\n*/\n\n\nmk.zeros\u003cDouble\u003e(3, 4) // create an array of zeros\n/*\n[[0.0, 0.0, 0.0, 0.0],\n[0.0, 0.0, 0.0, 0.0],\n[0.0, 0.0, 0.0, 0.0]]\n*/\nmk.ndarray\u003cFloat, D2\u003e(setOf(30f, 2f, 13f, 12f), intArrayOf(2, 2)) // create an array from a collection\n/*\n[[30.0, 2.0],\n[13.0, 12.0]]\n*/\n\nval d = mk.ndarray(\n    doubleArrayOf(1.0, 1.3, 3.0, 4.0, 9.5, 5.0),\n    2, 3\n) // create an array of shape(2, 3) from a primitive array\n/*\n[[1.0, 1.3, 3.0],\n[4.0, 9.5, 5.0]]\n*/\n\nmk.d3array(2, 2, 3) { it * it } // create an array of 3 dimension\n/*\n[[[0, 1, 4],\n[9, 16, 25]],\n\n[[36, 49, 64],\n[81, 100, 121]]]\n*/\n\nmk.d2arrayIndices(3, 3) { i, j -\u003e ComplexFloat(i, j) }\n/*\n[[0.0+(0.0)i, 0.0+(1.0)i, 0.0+(2.0)i],\n[1.0+(0.0)i, 1.0+(1.0)i, 1.0+(2.0)i],\n[2.0+(0.0)i, 2.0+(1.0)i, 2.0+(2.0)i]]\n */\n\nmk.arange\u003cLong\u003e(10, 25, 5) // create an array with elements in the interval [10, 25) with step 5\n/* [10, 15, 20] */\n\nmk.linspace\u003cDouble\u003e(0, 2, 9) // create an array of 9 elements in the interval [0, 2]\n/* [0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0] */\n\nval e = mk.identity\u003cDouble\u003e(3) // create an identity array of shape (3, 3)\n/*\n[[1.0, 0.0, 0.0],\n[0.0, 1.0, 0.0],\n[0.0, 0.0, 1.0]]\n*/\n\nval diag = mk.diagonal(mk[2, 4, 8]) // create a diagonal array\n/*\n[[2, 0, 0],\n[0, 4, 0],\n[0, 0, 8]]\n */\n```\n\n\u003c!---END--\u003e\n\n### Array properties\n\n\u003c!---FUN arrayProperties--\u003e\n\n```kotlin\na.shape // Array dimensions\na.size // Size of array\na.dim // object Dimension\na.dim.d // number of array dimensions\na.dtype // Data type of array elements\n```\n\n\u003c!---END--\u003e\n\n### Arithmetic operations\n\n\u003c!---FUN arithmeticOperations--\u003e\n\n```kotlin\nval f = b - d // subtraction\n/*\n[[0.5, 0.8, 0.0],\n[0.0, -4.5, 1.0]]\n*/\n\nd + f // addition\n/*\n[[1.5, 2.1, 3.0],\n[4.0, 5.0, 6.0]]\n*/\n\nb / d // division\n/*\n[[1.5, 1.6153846153846154, 1.0],\n[1.0, 0.5263157894736842, 1.2]]\n*/\n\nf * d // multiplication\n/*\n[[0.5, 1.04, 0.0],\n[0.0, -42.75, 5.0]]\n*/\n```\n\n\u003c!---END--\u003e\n\n### Math, Linear Algebra, and Statistics\n\nSee documentation for other methods of\n[mathematics](https://kotlin.github.io/multik/multik-core/org.jetbrains.kotlinx.multik.api.math/index.html),\n[linear algebra](https://kotlin.github.io/multik/multik-core/org.jetbrains.kotlinx.multik.api.linalg/index.html),\n[statistics](https://kotlin.github.io/multik/multik-core/org.jetbrains.kotlinx.multik.api.stat/index.html).\n\n\u003c!---FUN mathFunctions--\u003e\n\n```kotlin\na.sin() // element-wise sin, equivalent to mk.math.sin(a)\na.cos() // element-wise cos, equivalent to mk.math.cos(a)\nb.log() // element-wise natural logarithm, equivalent to mk.math.log(b)\nb.exp() // element-wise exp, equivalent to mk.math.exp(b)\nd dot e // dot product, equivalent to mk.linalg.dot(d, e)\n\nmk.math.sum(c) // array-wise sum\nmk.math.min(c) // array-wise minimum elements\nmk.math.maxD3(c, axis = 0) // maximum value of an array along axis 0\nmk.math.cumSum(b, axis = 1) // cumulative sum of the elements\nmk.stat.mean(a) // mean\nmk.stat.median(b) // median\n```\n\n\u003c!---END--\u003e\n\n### Copying arrays\n\n\u003c!---FUN copyingArrays--\u003e\n\n```kotlin\nval f = a.copy() // create a copy of the array and its data\nval h = b.deepCopy() // create a copy of the array and copy the meaningful data\n```\n\n\u003c!---END--\u003e\n\n### Collection Operations\n\n\u003c!---FUN collectionOperations--\u003e\n\n```kotlin\nc.filter { it \u003c 3 } // select all elements less than 3\nb.map { (it * it).toInt() } // return squares\nc.groupNDArrayBy { it % 2 } // group elements by condition\nc.sorted() // sort elements\n```\n\n\u003c!---END--\u003e\n\n### Indexing/Slicing/Iterating\n\n\u003c!---FUN indexingSlicingIterating--\u003e\n\n```kotlin\na[2] // select the element at the 2 index\nb[1, 2] // select the element at row 1 column 2\nb[1] // select row 1\nb[0..1, 1] // select elements at rows 0 to 1 in column 1\nb[0, 0..2..1] // select elements at row 0 in columns 0 to 2 with step 1\n\nfor (el in b) {\n    print(\"$el, \") // 1.5, 2.1, 3.0, 4.0, 5.0, 6.0,\n}\n\n// for n-dimensional\nval q = b.asDNArray()\nfor (index in q.multiIndices) {\n    print(\"${q[index]}, \") // 1.5, 2.1, 3.0, 4.0, 5.0, 6.0,\n}\n```\n\n\u003c!---END--\u003e\n\n### Inplace\n\n\u003c!---FUN inplaceOperations--\u003e\n\n```kotlin\nval a = mk.linspace\u003cFloat\u003e(0, 1, 10)\n/*\na = [0.0, 0.1111111111111111, 0.2222222222222222, 0.3333333333333333, 0.4444444444444444, 0.5555555555555556,\n0.6666666666666666, 0.7777777777777777, 0.8888888888888888, 1.0]\n*/\nval b = mk.linspace\u003cFloat\u003e(8, 9, 10)\n/*\nb = [8.0, 8.11111111111111, 8.222222222222221, 8.333333333333334, 8.444444444444445, 8.555555555555555,\n8.666666666666666, 8.777777777777779, 8.88888888888889, 9.0]\n*/\n\na.inplace {\n    math {\n        (this - b) * b\n        abs()\n    }\n}\n// a = [64.0, 64.88888, 65.77778, 66.66666, 67.55556, 68.44444, 69.333336, 70.22222, 71.111115, 72.0]\n```\n\n\u003c!---END--\u003e\n\n## Building\n\n### Full build (with OpenBLAS)\n\nRequires:\n\n* `JAVA_HOME` environment variable set\n* `gcc`, `g++`, `gfortran` version 8 or higher (must be the same version)\n\n```bash\n./gradlew assemble\n```\n\n### Without OpenBLAS\n\n```bash\n./gradlew assemble -x build_cmake\n```\n\n### Individual modules\n\n```bash\n./gradlew :multik-core:build\n```\n\n### Running tests\n\n```bash\n./gradlew :multik-core:jvmTest\n```\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on submitting issues, pull requests, and building the project.\n\n## License\n\nMultik is licensed under the [Apache License 2.0](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkotlin%2Fmultik","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkotlin%2Fmultik","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkotlin%2Fmultik/lists"}