Skip to content

[ADD]: Generic Matrix<T> 2D Array Type to Kotlin Standard Library #5428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

krishpranav
Copy link

Description:

new class Matrix<T> to the Kotlin Standard Library under kotlin.collections, providing idiomatic, type-safe 2D array support for Kotlin developers. While Kotlin offers powerful tools for 1D arrays and collection APIs, native 2D array support has been a long-requested feature

Issue:

Features:

  • Generic, type-safe 2D structure: Matrix<T>
  • Backed by a flat 1D array for memory and cache efficiency
  • Intuitive access via matrix[row, col] using operator overloading
  • Full bounds checking with informative errors
  • Clear and concise implementation with extensibility in mind
  • Designed for performance without sacrificing Kotlin idioms

@fzhinkin
Copy link
Contributor

fzhinkin commented Apr 8, 2025

@krishpranav is there a particular use-case for the proposed API? As of now the implementation does almost nothing except providing 2D-addressing to elements and it is not clear how it could be used to solve practical problems which usually require matrices.

If you believe that it is a time to add a matrix API into the stdlib, please hit the YT issue (KT-1140) and describe your use cases, so it could be considered.

In the current form this PR will not be accepted. There are a few issues with code itself (no tests were added, lack of samples in the documentation, outdated Kotlin version in @SinceKotlin, to name a few), but that is something that could be fixed. The main blocker is that the API itself needs to be designed and discussed first (you can check other posted proposals to get a sense of how it works).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants