This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Multik is a Kotlin Multiplatform library for multidimensional arrays (ndarray), providing math, linear algebra, and
statistics operations. JetBrains incubator project (alpha stability). Group ID: org.jetbrains.kotlinx, version defined
in gradle.properties.
- multik-core — Core ndarray types, the
Multik(mk) entry-point object, and API interfaces (Math,LinAlg,Statistics). All platforms. JVM-only: CSV/NPY IO viacommons-csvandbio-npy. - multik-kotlin — Pure Kotlin engine (
KEEngine). JVM + Native + JS + WASM. - multik-openblas — Native engine (
NativeEngine) using OpenBLAS via C++/JNI. JVM + desktop Native only (no iOS/JS/WASM). C++ source inmultik-openblas/multik_jni/. - multik-default — Combines multik-kotlin and multik-openblas via
DefaultEngine/DefaultEngineFactory. PicksNativeEngineon supported platforms, falls back toKEEngine.
# Build all modules (requires: gcc/g++/gfortran 8+, JAVA_HOME set)
./gradlew assemble
# Build without native OpenBLAS (skip the CMake step)
./gradlew assemble -x build_cmake
# Build only core module
./gradlew :multik-core:buildCMake build uses env vars: CMAKE_C_COMPILER, CMAKE_CXX_COMPILER, GCC_LIB_Path, TARGET_OS.
Task chain: createBuildDir → configureCmake → compileCmake → copyNativeLibs → build_cmake.
# JVM tests (JUnit Platform)
./gradlew :multik-core:jvmTest
./gradlew :multik-kotlin:jvmTest
./gradlew :multik-openblas:jvmTest # requires built native lib (build_cmake)
# Single test class
./gradlew :multik-core:jvmTest --tests "org.jetbrains.kotlinx.multik.creation.Create2DIntArrayTests"
# Native tests (host target only)
./gradlew :multik-core:macosArm64Test # or linuxX64Test, mingwX64Test- Name test functions
testXxx— no backticks in test names. - Test classes use
*Test/*Testssuffix. multik-openblastests extendNativeTestBasewhich callslibLoader("multik_jni").manualLoad()in@BeforeTest. The JVM test task setsjava.library.pathtobuild/cmake-build.
The Multik object (aliased as mk) delegates to an Engine providing Math, LinAlg, and Statistics.
Engines: KEEngine (pure Kotlin, all platforms), NativeEngine (OpenBLAS, JVM + desktop Native),
DefaultEngine (picks best available). Engine loading is platform-specific via expect fun enginesProvider().
- Kotlin 2.3.10 with
-Xexpect-actual-classescompiler flag. JVM target: 11. - All development happens on the
developbranch — base PRs againstdevelop. - Convention plugins in
buildSrc/src/main/kotlin/.
Follow the Kotlin library authors' guidelines. Key Multik-specific rules:
- No data classes in public API — adding properties breaks binary compatibility. Use regular classes with explicit
toString. - No new arguments on existing public functions, even with defaults — breaks binary compatibility on JVM. Use manual overloads.
- Never widen or narrow return types of existing public functions.
- Use
@Deprecatedwithmessage,replaceWith, and progressivelevel(WARNING → ERROR → HIDDEN). - Use
@RequiresOptIn(e.g.@ExperimentalMultikApi) for new unstable APIs. - Core model is
NDArray<T, D>+MemoryView+Engine— new operations should compose with these, not introduce parallel hierarchies. - Place APIs in the broadest relevant source set (
commonMainfirst).
- Use
[ClassName]/[functionName]references for cross-links. - Document view-vs-copy semantics explicitly.
- See the
multik-kdocskill for the full KDoc style guide and audit workflow.
- Writerside docs in
docs/(config:docs/mk.tree). - API docs generated with Dokka:
./gradlew dokkaGenerate. - Doc samples validated by the Korro plugin. Samples live in
multik-core/src/commonTest/kotlin/samples/docs/and map todocs/topics/**/*.md. Code blocks in sample files are delimited with// SampleStartand// SampleEndcomments. Keep samples and markdown in sync. - See the
multik-docsskill for Writerside page templates and conventions.