Skip to main content

A lightweight, NumPy-powered linear algebra toolkit for Python with a clean matrix API

Project description

LinAlgKit

Docs CI Wheels PyPI

LinAlgKit Banner

LinAlgKit is a lightweight, NumPy-powered linear algebra toolkit for Python. It offers a minimal, clean API for matrices with scientific computing essentials: construction, arithmetic, transpose, trace, and determinant — all with first-class NumPy interoperability.

Features

  • Supports multiple numeric dtypes: int, float32, float64
  • Clean matrix API: +, -, * (matrix and scalar), transpose(), trace(), determinant()
  • Constructors: identity(n), zeros(r, c), ones(r, c)
  • NumPy interop: .from_numpy(ndarray), .to_numpy()
  • Pure Python packaging — quick pip install on any platform

Installation

pip install -U pip
pip install LinAlgKit

Editable install for development:

pip install -U pip
pip install -e .

Quickstart

import numpy as np
import LinAlgKit as lk

# Construct from NumPy
A = lk.Matrix.from_numpy(np.array([[1.0, 2.0], [3.0, 4.0]]))
B = lk.Matrix.identity(2)

# Core ops
C = A + B
AT = A.transpose()
detA = A.determinant()

print("C =\n", C.to_numpy())
print("AT =\n", AT.to_numpy())
print("det(A) =", detA)

Python API overview

  • Matrix, MatrixF, MatrixI classes with common operations
  • Functional helpers: array, zeros, ones, eye, matmul, transpose, trace, det
  • NumPy interop by design (copy in both directions for safety)

Design Philosophy

  • Vectorization-first: prefer NumPy operations and shapes that compose well.
  • Minimal surface area: focus on the 80% of linear algebra tasks used daily.
  • Explicit data flow: .from_numpy() and .to_numpy() are copy-based and clear.
  • Pythonic ergonomics: a small, predictable API that reads like the math.
  • Interop-ready: functions also accept NumPy arrays where sensible.

Why LinAlgKit? (vs. raw NumPy)

  • Matrix-first API with clear semantics (Matrix, transpose(), determinant()), helpful for pedagogy and readability.
  • Convenience constructors (identity, zeros, ones) aligned with matrix mental models.
  • Gentle learning curve for users coming from linear algebra courses before diving into broader NumPy idioms.
  • Clean separation between object API and functional helpers so you can mix OO and vectorized styles.

Testing

python -m pip install -U pytest
pytest -q

NumPy interop

  • Matrix/MatrixF/MatrixI.from_numpy(array) constructs from a 2D ndarray (copy)
  • .to_numpy() returns a 2D ndarray (copy)
  • For vectorized workflows, you can also use the functional API (matmul, trace, det) directly on NumPy arrays

Examples

from LinAlgKit import array, eye, matmul, det

A = array([[1., 2.], [3., 4.]])
I = eye(2)
print(det(A))         # -> -2.0
print(matmul(A, I))   # -> A

Scientific notes

  • Determinant, trace, and matmul are delegated to NumPy/numpy.linalg where applicable
  • API emphasizes clarity and composability; best used together with NumPy idioms

Benchmarks

For research-grade benchmarking, consider asv or simple scripts using timeit with NumPy arrays. A basic harness can be added in scripts/ if needed.

Roadmap

  • Convenience APIs (slicing helpers, broadcasting-aware ops)
  • Optional SciPy interop (sparse CSR constructors)
  • Expanded tests and property-based testing
  • Example notebooks and gallery in docs/

Citation

If you use LinAlgKit in academic work, please cite this repository:

@software{linalgkit2025,
  author  = {SciComputeOrg},
  title   = {LinAlgKit: A Lightweight Linear Algebra Toolkit for Python},
  year    = {2025},
  url     = {https://github.com/SciComputeOrg/LinAlgKit}
}

License

This project is licensed under the Apache License 2.0 — see the LICENSE file for details.

Contributing

Contributions are welcome! Please open issues and pull requests. For larger features (e.g., sparse matrices), open a design discussion first.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linalgkit-0.1.0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linalgkit-0.1.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file linalgkit-0.1.0.tar.gz.

File metadata

  • Download URL: linalgkit-0.1.0.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for linalgkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cf08a87c8752618586805503d837a8dae9c0b87c7c20db975bd73d543a8482a3
MD5 2ba6ee465fcfe86bdfe6d532426dd3b2
BLAKE2b-256 bcebe21120d9affe6457c5527be30957d5412482daa8d782da63d19063ef6dfd

See more details on using hashes here.

File details

Details for the file linalgkit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: linalgkit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for linalgkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd3f6baff7f90479c43ac80824c6929e44c99bda151291093bd9d209828de897
MD5 61eaa3ed715f7b06f2b60b2863e32f13
BLAKE2b-256 74dd355c3bcbcc44dc8fc8b4289775d5856f4dda70c95dd4b3fe716a611e7ea9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page