Skip to main content

A pure-Python linear algebra package with matrices, vectors, and manual numerical algorithms.

Project description

linearean

A small linear algebra package written from scratch in pure Python. It provides matrix and vector data structures, manual Gaussian-elimination based routines, power iteration, and extensions for complex-valued linear algebra, tensor products, and Markov-chain checks.

The package intentionally avoids high-level numerical libraries so the core algorithms are easy to read and study.

Features

  • Matrix and Vector classes with dimension validation.
  • Operator overloading for +, -, scalar *, and matrix multiplication with @.
  • Determinants and inverses using manual Gaussian elimination / Gauss-Jordan elimination with partial pivoting.
  • Linear solves, rank, reduced row echelon form, trace, transpose, and norms.
  • Power iteration for the dominant eigenvalue and eigenvector.
  • Complex conjugate transpose, Hermitian/unitary checks, Kronecker products, tensor powers, and stochastic-matrix validation.

Quick start

from linearean import Matrix, Vector, power_iteration
from linearean.extensions import kronecker_product, is_stochastic

A = Matrix([[2, 1], [5, 3]])
B = Matrix([[1, 0], [0, 1]])
v = Vector([1, 2])

print(A + B)
print(A @ v)
print(A.determinant())
print(A.inverse())

eigenvalue, eigenvector = power_iteration(A)
print(eigenvalue, eigenvector)

coin = Matrix([[0.5, 0.5], [0.5, 0.5]])
print(is_stochastic(coin))

system = kronecker_product(B, B)
print(system)

Development

Run tests with:

python -m unittest discover

Install locally in editable mode with:

python -m pip install -e .

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

linearean-0.1.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

linearean-0.1.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file linearean-0.1.1.tar.gz.

File metadata

  • Download URL: linearean-0.1.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for linearean-0.1.1.tar.gz
Algorithm Hash digest
SHA256 08c20208c6a9556b120d7844d6028d67c4c54afec9df1f63b6c9d794c950a605
MD5 279c7197db6a1627554a925b2ac68c3f
BLAKE2b-256 622c316c74e287a5ddba15ecc0d23ee83a00233a2b31343e7011b9b7cc56bf23

See more details on using hashes here.

File details

Details for the file linearean-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: linearean-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for linearean-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 76bfef19b3b7bce3a4996f5112fbb3e77576d98140d4ed0c5edfd0619460356e
MD5 fb6dc4a43383032d4040cf563789a332
BLAKE2b-256 4706c0a4ab74b07b8ec78787de107da7e2d2dcd65561900dfdf1062fa34d24f1

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