Skip to main content

A Python-native linear algebra library for learning, experimentation, and visual intuition

Project description

panchi

panchi is a Python-native linear algebra library designed for learning, experimentation, and visual intuition.

The goal is not performance. The goal is clarity.

TestCI PyPI version Python 3.10+ License: MIT Code style: black


Why panchi?

Most linear algebra libraries optimize for speed and abstraction. panchi optimizes for understanding.

panchi is built for:

  • Students learning linear algebra who want to see the math happen, not just trust a black box
  • Educators who need transparent implementations to demonstrate concepts in lectures or workshops
  • Self-learners building intuition through experimentation and visual feedback
  • Researchers prototyping algorithms where readability matters more than runtime
  • Developers who want to understand what's happening under the hood before optimizing

Think of panchi as a laboratory notebook, not a production engine.


Philosophy

  1. Explicit over implicit – Algorithms are implemented directly, not delegated to opaque backends
  2. Readable over clever – Code prioritizes clarity and educational value over terse optimizations
  3. Mathematical over computational – Objects behave like mathematical entities with proper operator overloading
  4. Visual by default – Visualization is a first-class feature, not an afterthought
  5. Informative errors – Error messages guide learning by explaining what went wrong and why

Features

✅ Currently Available

Core Primitives

  • Vector and Matrix classes with native Python data structures
  • Natural mathematical syntax through operator overloading (+, -, *, **)
  • Comprehensive shape checking with educational error messages

Vector Operations

  • Addition, subtraction, scalar multiplication
  • Magnitude calculation and normalization
  • Dot product and cross product (3D)
  • Unit vectors and zero vectors

Matrix Operations

  • Addition, subtraction, matrix multiplication
  • Scalar multiplication and matrix powers
  • Transpose operations
  • Matrix-vector transformations
  • Trace calculation for square matrices

Utilities

  • Identity matrices and zero matrices
  • Random vectors and matrices with configurable ranges
  • 2D and 3D rotation matrices
  • Diagonal matrix construction

🚧 In Development

  • Matrix determinants and inverses
  • Matrix decompositions (LU, QR, eigenvalue methods)
  • Interactive visualization toolkit
  • Animated transformations
  • Jupyter notebook integration

🔮 Roadmap

  • Step-by-step algorithm demonstrations
  • Educational machine learning examples (PCA, linear regression)
  • Physics simulations using linear operators
  • Extended documentation with visual explanations

Installation

pip install panchi

Requirements: Python 3.10 or higher

For the optional Manim-powered visualizations:

pip install panchi[manim]

To install from source for development:

git clone https://github.com/Gustavo-Galvao-e-Silva/panchi.git
cd panchi
pip install -e ".[dev]"

Quick Start

from panchi.primitives import Vector, Matrix
from panchi.operations import dot, identity, rotation_matrix_2d
from math import pi

# Vector operations
v = Vector([3, 4])
magnitude = v.magnitude
normalized = v.normalize()

# Matrix transformations
rotation = rotation_matrix_2d(pi / 2)
point = Vector([1, 0])
rotated = rotation * point

# Matrix algebra
A = Matrix([[1, 2], [3, 4]])
B = Matrix([[5, 6], [7, 8]])
C = A * B
trace = C.trace

# Identity and special matrices
I = identity(3)
product = A * A.right_identity

Use Cases

1. Learning Linear Algebra

Work through textbook problems with code that mirrors mathematical notation:

# Verify that (AB)^T = B^T A^T
A = Matrix([[1, 2], [3, 4]])
B = Matrix([[5, 6], [7, 8]])

left_side = (A * B).T
right_side = B.T * A.T

assert left_side == right_side

Contributing

panchi welcomes contributions that align with its educational mission:

  1. Clarity First – Code should be readable by someone learning linear algebra
  2. Tests Required – All new features need comprehensive pytest tests
  3. Descriptive Docstrings – Follow NumPy documentation style
  4. Mathematical Accuracy – Verify implementations against textbook algorithms

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/determinant-calculation)
  3. Write clear, well-documented code with tests
  4. Ensure all tests pass (pytest tests/)
  5. Submit a pull request with a detailed description

See CONTRIBUTING.md for detailed guidelines.


Documentation

Full documentation will be available at panchi.readthedocs.io (coming soon)

  • API Reference – Complete function and class documentation
  • Tutorials – Step-by-step guides for common operations
  • Examples – Real-world use cases and demonstrations
  • Theory – Mathematical background and explanations

Project Status

Current Version: 0.1.0a1 (Alpha)

panchi is in early alpha. It is installable and the core primitives are functional, but APIs may change as the library evolves. Not recommended for production use. Feedback and contributions are very welcome.


Support


License

MIT License – see LICENSE for details.


Acknowledgments

panchi is inspired by educational resources that prioritize understanding:

  • Gilbert Strang's Introduction to Linear Algebra
  • 3Blue1Brown's Essence of Linear Algebra video series
  • The desire to make linear algebra accessible and visual

Final Note

panchi exists to answer a simple question:

"What is linear algebra actually doing?"

If you've ever felt frustrated by libraries that hide the mathematics behind abstractions, or if you want to see transformations happen rather than just trust the output, panchi is for you.

Linear algebra is beautiful. Let's make it visible.

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

panchi-0.1.0a1.tar.gz (32.6 kB view details)

Uploaded Source

Built Distribution

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

panchi-0.1.0a1-py3-none-any.whl (34.6 kB view details)

Uploaded Python 3

File details

Details for the file panchi-0.1.0a1.tar.gz.

File metadata

  • Download URL: panchi-0.1.0a1.tar.gz
  • Upload date:
  • Size: 32.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for panchi-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 0dddcfbe8c2907be006ddd880edaf0fd289bab3f32c7250ca5235799d9eea564
MD5 a3da631e28ce74f3806bce543db7942c
BLAKE2b-256 cb439bd70bcbe165f9a23238740d9d2085a8aa7a5c3da67a7e82bf54d0fe373b

See more details on using hashes here.

File details

Details for the file panchi-0.1.0a1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for panchi-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 bcaa6d669b2bb08f95e560a917010e0431ee03df748aa29c45a69ea96af80d0a
MD5 f0226e6ab14d071bbaf2c3d3eab06438
BLAKE2b-256 1901fbc5cfe2991ab29c4990bca029f5e3570ab7f3febaee4a3894a15797db66

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