Skip to main content

A nice linear algebra library

Project description

pylinlin PyPI version codecov

Nice linear algebra library in python

Examples

from pylinlin.matrix import Matrix
from pylinlin.lu_factorization import compute_lu_factorization
from pylinlin.qr_factorization import compute_qr_factorization

# Create matrix
matrix = Matrix.from_cols([[1, 2, 3], [4, 5, 6], [7, 8, 10]])  # preferred way to initialize a matrix
matrix2 = Matrix.from_rows([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

column_as_list = [1, 2, 3, 4, 5]
column_vector = Matrix.from_cols([column_as_list])  # column vectors can be represented as matrices
magnitude_sq = column_vector.transpose().multiply(column_vector).get(0, 0)  # 55

print(matrix.size())      # Get dimensions of matrix (rows, columns)
print(matrix.get_col(0))  # Get first column from matrix
print(matrix.get_row(1))  # Get second row from matrix

print(matrix.all_cols())  # List of matrix columns

matL, matU = compute_lu_factorization(matrix)
matQ, matR = compute_qr_factorization(matrix)
print(matQ.all_cols())
print(matQ.transpose().multiply(matQ).all_cols())  # approximately an identity matrix

product = matrix.multiply(matrix)  # matrix multiplication

Goals

  • Test-driven development
  • Profiling of performance
  • Profiling of numerical stability
  • Lightweight, easy to port over to other languages

TODOs

Algorithms

  • LU factorization
  • LU factorization with partial pivoting
  • QR factorization with householder matrices
  • QR factorization with pivoting
  • Gram Schmidt and Modified Gram Schmidt (help wanted!)
  • Spectral decomposition
  • SVD
  • Conjugate gradients
  • Condition number of a matrix
  • Jacobi SVD
  • Power iteration
  • Matrix Pseudoinverse

Profiling

  • Profile time taken varying size of matrices
  • Profile time taken to solve linear system comparing different algorithms
  • Graph error distribution on random matrices

Others

  • Make curve fitting demonstration
  • Make IK demonstration

Project details


Download files

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

Files for pylinlin, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size pylinlin-0.0.4.tar.gz (9.9 kB) File type Source Python version None Upload date Hashes View
Filename, size pylinlin-0.0.4-py3-none-any.whl (14.1 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page